Skip to content

Commit c9942ff

Browse files
Support any language
1 parent f6d1791 commit c9942ff

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

md_dead_link_check/preprocess.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ def process_header_to_fragment(header: str) -> str:
6868
fragment = fragment.replace(res.group(0), res.group(2))
6969

7070
fragment = fragment.lower().replace(" ", "-")
71-
fragment = re.sub(r"[^a-z0-9-_]", "", fragment)
71+
72+
def filter_header_symbols(c: str) -> bool:
73+
return c.isalpha() or c.isdigit() or c in ["-", "_"]
74+
75+
fragment = "".join(filter(filter_header_symbols, fragment))
7276
return fragment
7377

7478

tests/test_preprocess.py

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ def test_find_all_markdowns_in_repo():
3535
("H $ maths $", "h--maths-"),
3636
("H [text](link)", "h-text"),
3737
("H [![text](link)](link)", "h-"),
38+
("🙀 header with icon", "-header-with-icon"),
39+
("דוגמא", "דוגמא"),
40+
("例子", "例子"),
3841
),
3942
)
4043
def test_process_header_to_fragment(header, fragment):

0 commit comments

Comments
 (0)