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