Stop the floating ] on internal links

This commit is contained in:
rmgr 2022-04-11 17:33:37 +09:30
parent 6d58810472
commit 3edbe684d7
1 changed files with 10 additions and 4 deletions

View File

@ -138,12 +138,15 @@ def search_line_for_links(output_path, line, base_dir, page_title):
if line[i + 1] == "[":
found_link = True
for u in range(i + 2, len(line)):
if line[u] == "]":
if line[u-1] == "]" and line[u] == "]" :
process_link(output, link_text)
break
else:
link_text += line[u]
#We don't want markup in our links
if line[u] != "]":
link_text += line[u]
elif c == "#" and not line[i+1].isspace():
found_tag = True
link_text = ""
@ -183,8 +186,11 @@ def search_line_for_links(output_path, line, base_dir, page_title):
image_link += line[u]
elif found_tag and c in ['\r','\n',' ']:
found_tag = False
elif found_link and c in ["]", ">"]:
if line[i-1] in ["]", ">"]:
elif found_link and c in ["<"]:
if line[i-1] in [ ">"]:
found_link = False
elif found_link and c == "[":
if line[i-2] == "]":
found_link = False
elif found_image and line[i-1] in [")"]:
found_image = False