Skip to content

Commit 960ae34

Browse files
committed
fix: hash in table of contents
Closes: #675
1 parent e09fb90 commit 960ae34

6 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/markdown2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,7 @@ def _h_tag_sub(self, match: re.Match[str]) -> str:
16551655
text = match.string[match.start(): match.end()]
16561656
h_level = int(match.group(1))
16571657
# extract id= attr from tag, trying to account for regex "misses"
1658-
id_attr = (re.match(r'.*?id=(\S+)?.*', match.group(2) or '') or '')
1658+
id_attr = (re.match(r'.*?id="(\S+)?".*', match.group(2) or '') or '')
16591659
if id_attr:
16601660
# if id attr exists, extract that
16611661
id_attr = id_attr.group(1) or ''
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1 id="bla"><code>bla</code></h1>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"extras": {"toc": {"depth": 1}, "header-ids": {"mixed": True }}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
toc extra issue675
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# `bla`
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<ul>
2+
<li><a href="#bla"><code>bla</code></a></li>
3+
</ul>

0 commit comments

Comments
 (0)