From 0d9c5d888bfe3b19c8812f96805b459b0e4b0108 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 6 Dec 2022 14:48:57 +0000 Subject: [PATCH] Bookmark links --- markdown.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/markdown.py b/markdown.py index 355e79025..b83074705 100644 --- a/markdown.py +++ b/markdown.py @@ -198,10 +198,16 @@ def _markdown_replace_links(markdown: str) -> str: section_text = \ section_text.replace('!' + replace_str, html_link) if replace_str in section_text: - html_link = \ - '' + \ - link_text + '' + if not link_url.startswith('#'): + # external link + html_link = \ + '' + \ + link_text + '' + else: + # bookmark + html_link = \ + '' + link_text + '' section_text = \ section_text.replace(replace_str, html_link) ctr += 1