Commit 5d6a0aaa authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Fix regex for markdown links

parent 4799c0df
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -353,9 +353,12 @@ class Document:
		# Replace the markdown links
		for clause in self.clauses:
			for i, line in enumerate(clause.lines):
				if (links := markdownLink.findall(line.text)):
				if not line.text.strip().startswith('![') and (links := markdownLink.findall(line.text)):
					# Replace the old link targets with converted 
					# (lower case) versions that point to the output files
					printDebug(f'Found Markdown links in clause "{clause.title}": {links}')
					# Remove duplicate matches in links list
					links = list(set(links))
					for lnk in links:
						_lnk =lnk.casefold()
						if _lnk in linkTargets:
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ matchHtmlAnchorLink = re.compile(r'<a\s+name="([^"]*)">[^<]*</a>', re.IGNORECASE
matchHtmlLink = re.compile(r'<a\s+href="([^"\']*)">[^<]*</a>', re.IGNORECASE)
matchHtmlTag = re.compile(r'<[^>]*>', re.IGNORECASE)
MatchInlineFootnote = re.compile(r'\[\^([^\]]*)\]', re.IGNORECASE)
markdownLink = re.compile(r'[^!]\[[^\]]*\]\((#[^)]*)\)', re.IGNORECASE)
markdownLink = re.compile(r'\[(?:(?:\\\[)?(?:[^]]*)(?:\\\])?)\]\((#[^)]*)\)', re.IGNORECASE)
matchCodefenceStart = re.compile(r'\s*```\s?.*', re.IGNORECASE)
matchCodefenceEnd = re.compile(r'\s*```\s?', re.IGNORECASE)
matchGridTable = re.compile(r'^\s*\+-.*\+\s$', re.IGNORECASE)