From 4a5e7f5ada66f2d051a4f904797a11214e5406da Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 27 Mar 2024 14:29:12 +0000 Subject: [PATCH] Support jumping to a document heading --- ChangeLog.md | 2 ++ frogmouth/screens/main.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index ab19810..bda3ff7 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,6 +6,8 @@ - Front matter is now ignored when viewing a file. [#15](https://github.com/Textualize/frogmouth/issues/15) +- Added support for jumping to an internal anchor. + [#91](https://github.com/Textualize/frogmouth/issues/91) ## [0.9.2] - 2023-11-28 diff --git a/frogmouth/screens/main.py b/frogmouth/screens/main.py index b2136b7..f6f1a43 100644 --- a/frogmouth/screens/main.py +++ b/frogmouth/screens/main.py @@ -411,6 +411,12 @@ def on_markdown_link_clicked(self, event: Markdown.LinkClicked) -> None: # document we found it exists in the local filesystem, so let's # assume that's what we're supposed to handle. self.visit(local_file) + elif event.href.startswith("#") and event.markdown.goto_anchor(event.href[1:]): + # The href started with a # and the remains of it were satisfied + # as an anchor within the document of the Markdown. We should + # have scrolled to about the right spot in the document so we + # don't need to do anything else. + pass else: # Yeah, not sure *what* this link is. Rather than silently fail, # let's let the user know we don't know how to process this.