From e4c4472a40db4d06cb1fa4df7c6b76d25b4e8375 Mon Sep 17 00:00:00 2001 From: Peter Yuen Date: Sat, 26 Mar 2022 21:19:03 +0800 Subject: [PATCH] Fixed heading tag error --- convert.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/convert.py b/convert.py index 70d27165..4a8097f0 100644 --- a/convert.py +++ b/convert.py @@ -132,9 +132,12 @@ def filter_lines(file: Path, content: List[str]) -> List[str]: # Markdown links: [xxx](yyy) # (\[.+?\]): Capture [xxx] part # \((?!http)(.+?)(?:.md)?\): Capture (yyy) part, ensuring that link is not http and remove .md from markdown files + # (#.+)?: Capture any heading tags after ".md" replaced_links = [ re.sub( - r"(\[.+?\])\((?!http)(.+?)(?:.md)?\)", r"\1(" + parent_dir + r"/\2)", line + r"(\[.+?\])\((?!http)(.+?)(?:.md)?(#.+)?\)", + r"\1(" + parent_dir + r"/\2\3)", + line, ) for line in content ]