Skip to content

Commit

Permalink
Fix quotes in headers
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderDokuchaev committed Feb 28, 2024
1 parent dcc38d2 commit 46ca68a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions md_dead_link_check/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ 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:
fragment = process_header_to_fragment(res.group(1))
fragments.append(fragment)
continue

# Skip $ and ` tags
line = re.sub(RE_SUB, "", line)

# Detect links
matches = re.findall(RE_LINK, line)
if matches:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_md_files/a.md
Original file line number Diff line number Diff line change
Expand Up @@ -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$
2 changes: 2 additions & 0 deletions tests/test_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -47,6 +48,7 @@ def test_process_md_file():
"formula",
"grave",
"links",
"header-with-quotes-and-math",
]

ref_links = [
Expand Down

0 comments on commit 46ca68a

Please sign in to comment.