Skip to content

Commit

Permalink
Fix # fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderDokuchaev committed Jun 25, 2024
1 parent 912eabc commit 18cca8a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions md_dead_link_check/link_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ def check_path_links(
continue
md_abs_path = root_dir / md_file_info.path
for md_link in md_file_info.links:
if md_link.link == "#":
# Link on top of file
continue
if any(fnmatch(md_link.link, p) for p in config.exclude_links):
continue
split_result = urlsplit(md_link.link)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_md_files/a.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ Some text
#### Badge

[![GitHub Action](https://github.com/AlexanderDokuchaev/md-dead-link-check/actions/workflows/github_action.yml/badge.svg?branch=main "tag")](https://github.com/AlexanderDokuchaev/md-dead-link-check/actions/workflows/github_action.yml "tag")

<!-- markdownlint-disable -->

[top](#)

[top](./b.md#)
10 changes: 10 additions & 0 deletions tests/test_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,15 @@ def test_process_md_file():
location=Path("tests/test_md_files/a.md"),
line_num=36,
),
LinkInfo(
link="#",
location=Path("tests/test_md_files/a.md"),
line_num=40,
),
LinkInfo(
link="./b.md#",
location=Path("tests/test_md_files/a.md"),
line_num=42,
),
]
assert md_info.links == ref_links

0 comments on commit 18cca8a

Please sign in to comment.