Skip to content
Snippets Groups Projects
Commit c6f007f3 authored by Andreas Kraft's avatar Andreas Kraft
Browse files

Fixed missing links when multiple references are in the same line

parent c90c14c1
No related branches found
No related tags found
No related merge requests found
...@@ -219,6 +219,7 @@ def updateLinks(clauses:list[Clause]) -> list[Clause]: ...@@ -219,6 +219,7 @@ def updateLinks(clauses:list[Clause]) -> list[Clause]:
if (anchors := _htmlAnchorLink.findall(line)): if (anchors := _htmlAnchorLink.findall(line)):
for a in anchors: for a in anchors:
linkTargets[f'#{a}'] = (i, clause) linkTargets[f'#{a}'] = (i, clause)
print(f'[green]Found anchor "{a}" in clause "{clause.title}"')
# Replace the html links # Replace the html links
for clause in clauses: for clause in clauses:
...@@ -227,7 +228,7 @@ def updateLinks(clauses:list[Clause]) -> list[Clause]: ...@@ -227,7 +228,7 @@ def updateLinks(clauses:list[Clause]) -> list[Clause]:
for lnk in links: for lnk in links:
width = 4 width = 4
if lnk in linkTargets: 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 # Replace the markdown links
for clause in clauses: for clause in clauses:
...@@ -235,7 +236,7 @@ def updateLinks(clauses:list[Clause]) -> list[Clause]: ...@@ -235,7 +236,7 @@ def updateLinks(clauses:list[Clause]) -> list[Clause]:
if (links := _markdownLink.findall(line)): if (links := _markdownLink.findall(line)):
for lnk in links: for lnk in links:
if lnk in linkTargets: 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 return clauses
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment