Skip to content

Commit f655468

Browse files
committed
Fix a corner case with combine_header_slug and Tab and Tabbed
If there is no header before the tab, code could break
1 parent 3e8a097 commit f655468

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

docs/src/markdown/about/changelog.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- **FIX**: Tab and Tabbed: Fix a case where tabs could fail if `combine_header_slug` was enabled and there was no
6+
header.
7+
38
## 10.14.3
49

510
- **FIX**: Blocks: An empty, raw block type should not cause an error.

pymdownx/blocks/tab.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def get_parent_header_slug(self, root, header_map, parent_map, el):
3636
for i in list(parent):
3737
if i is el and header is None:
3838
break
39-
if i is last_parent:
39+
if i is last_parent and header is not None:
4040
return header.attrib.get("id", '')
4141
if i in headers:
4242
header = i

pymdownx/tabbed.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def get_parent_header_slug(self, root, header_map, parent_map, el):
327327
for i in list(parent):
328328
if i is el and header is None:
329329
break
330-
if i is last_parent:
330+
if i is last_parent and header is not None:
331331
return header.attrib.get("id", '')
332332
if i in headers:
333333
header = i

0 commit comments

Comments
 (0)