Commit c6f007f3 authored by ankraft's avatar ankraft
Browse files

Fixed missing links when multiple references are in the same line

parent c90c14c1
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -219,6 +219,7 @@ def updateLinks(clauses:list[Clause]) -> list[Clause]:
			if (anchors := _htmlAnchorLink.findall(line)):
				for a in anchors:
					linkTargets[f'#{a}'] = (i, clause)
					print(f'[green]Found anchor "{a}" in clause "{clause.title}"')

	# Replace the html links
	for clause in clauses:
@@ -227,7 +228,7 @@ def updateLinks(clauses:list[Clause]) -> list[Clause]:
				for lnk in links:
					width = 4
					if lnk in linkTargets:
						clause.lines[i] = line.replace(lnk, f'../{linkTargets[lnk][0]:0{width}}/#{lnk[1:]}')
						line = clause.lines[i] = line.replace(lnk, f'../{linkTargets[lnk][0]:0{width}}/#{lnk[1:]}')	# Update the current line as well

	# Replace the markdown links
	for clause in clauses:
@@ -235,7 +236,7 @@ def updateLinks(clauses:list[Clause]) -> list[Clause]:
			if (links := _markdownLink.findall(line)):
				for lnk in links:
					if lnk in linkTargets:
						clause.lines[i] = line.replace(lnk, f'../{linkTargets[lnk][0]:0{fnLength}}/#{lnk[1:]}')
						line = clause.lines[i] = line.replace(lnk, f'../{linkTargets[lnk][0]:0{fnLength}}/#{lnk[1:]}')	# Update the current line as well

	return clauses