From 46ca68ada34cbe5a932716d62430c6b33b3744b3 Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Wed, 28 Feb 2024 05:13:55 +0200 Subject: [PATCH] Fix quotes in headers --- md_dead_link_check/preprocess.py | 6 +++--- tests/test_md_files/a.md | 2 ++ tests/test_preprocess.py | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/md_dead_link_check/preprocess.py b/md_dead_link_check/preprocess.py index c330db9..9ac9b32 100644 --- a/md_dead_link_check/preprocess.py +++ b/md_dead_link_check/preprocess.py @@ -78,9 +78,6 @@ def process_md_file(path: Path, root_dir: Path) -> MarkdownInfo: if in_code_block: continue - # Skip $ and ` tags - line = re.sub(RE_SUB, "", line) - # Detect headers res = re.match(RE_HEADER, line) if res: @@ -88,6 +85,9 @@ def process_md_file(path: Path, root_dir: Path) -> MarkdownInfo: fragments.append(fragment) continue + # Skip $ and ` tags + line = re.sub(RE_SUB, "", line) + # Detect links matches = re.findall(RE_LINK, line) if matches: diff --git a/tests/test_md_files/a.md b/tests/test_md_files/a.md index d32e4fb..47018ff 100644 --- a/tests/test_md_files/a.md +++ b/tests/test_md_files/a.md @@ -28,3 +28,5 @@ Some text [b](./b.md) [d.a](b.md) `[A+B](A)` [d.a](./d/a.md) [d.a](/tests/test_md_files/d/a.md) + +### Header with `quotes` and $math$ diff --git a/tests/test_preprocess.py b/tests/test_preprocess.py index 3667a8d..53c81c5 100644 --- a/tests/test_preprocess.py +++ b/tests/test_preprocess.py @@ -30,6 +30,7 @@ def test_find_all_markdowns_in_repo(): ("Header 1", "header-1"), ("C++ ext", "c-ext"), ("H_I (H)", "h_i-h"), + ("A `quotes` f", "a-quotes-f"), ), ) def test_process_header_to_fragment(header, fragment): @@ -47,6 +48,7 @@ def test_process_md_file(): "formula", "grave", "links", + "header-with-quotes-and-math", ] ref_links = [