Skip to content

Commit

Permalink
Support any language
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderDokuchaev committed Jun 25, 2024
1 parent f6d1791 commit c9942ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion md_dead_link_check/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ def process_header_to_fragment(header: str) -> str:
fragment = fragment.replace(res.group(0), res.group(2))

fragment = fragment.lower().replace(" ", "-")
fragment = re.sub(r"[^a-z0-9-_]", "", fragment)

def filter_header_symbols(c: str) -> bool:
return c.isalpha() or c.isdigit() or c in ["-", "_"]

fragment = "".join(filter(filter_header_symbols, fragment))
return fragment


Expand Down
3 changes: 3 additions & 0 deletions tests/test_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def test_find_all_markdowns_in_repo():
("H $ maths $", "h--maths-"),
("H [text](link)", "h-text"),
("H [![text](link)](link)", "h-"),
("🙀 header with icon", "-header-with-icon"),
("דוגמא", "דוגמא"),
("例子", "例子"),
),
)
def test_process_header_to_fragment(header, fragment):
Expand Down

0 comments on commit c9942ff

Please sign in to comment.