Skip to content

Commit f4f97f7

Browse files
committed
🐛 Keep internal anchors working
1 parent b021819 commit f4f97f7

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/hike/widgets/viewer.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,11 @@ def _handle_link(self, message: Markdown.LinkClicked) -> None:
545545
# off, on the off-chance that there's an anchor involved still...
546546
file_name, _, anchor = message.href.partition("#")
547547

548+
# Some sort of internal anchor perhaps?
549+
if anchor and not file_name:
550+
message.markdown.goto_anchor(anchor)
551+
return
552+
548553
# A local file that exists?
549554
if (local_file := Path(file_name).expanduser()).exists():
550555
self.post_message(OpenLocation(local_file.resolve()))
@@ -560,10 +565,6 @@ def _handle_link(self, message: Markdown.LinkClicked) -> None:
560565
self.post_message(OpenLocation(local_file))
561566
return
562567

563-
# Some sort of internal anchor perhaps?
564-
if anchor and message.markdown.goto_anchor(anchor):
565-
return
566-
567568
# TODO: One case that isn't yet handled is a file name that also has
568569
# an anchor: `some-file.md#some-anchor`. We should handle that too
569570
# at some point.

0 commit comments

Comments
 (0)