Skip to content

Commit 19ec936

Browse files
authored
Fix issue with empty titles and Tabbed (#2901)
Fixes #2900
1 parent 4868783 commit 19ec936

6 files changed

Lines changed: 64 additions & 5 deletions

File tree

‎docs/src/markdown/about/changelog.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ icon: lucide/scroll-text
33
---
44
# Changelog
55

6+
## 10.22
7+
8+
- **FIX**: Tabbed: Fix issue where an empty title would cause an exception.
9+
610
## 10.21.3
711

8-
- **FIX**: Fix regression that allows a snippet to be loaded outside of the base path using directory traversal when
9-
`restrict_base_path` is enabled (the default). Found by @gistrec.
12+
- **FIX**: Snippets: Fix regression that allows a snippet to be loaded outside of the base path using directory
13+
traversal when `restrict_base_path` is enabled (the default). Found by @gistrec.
1014

1115
## 10.21.2
1216

‎pymdownx/__meta__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,5 @@ def parse_version(ver: str) -> Version:
193193
return Version(major, minor, micro, release, pre, post, dev)
194194

195195

196-
__version_info__ = Version(10, 21, 3, "final")
196+
__version_info__ = Version(10, 22, 0, "final")
197197
__version__ = __version_info__._get_canonical()

‎pymdownx/tabbed.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def run(self, parent, blocks):
172172

173173
if m:
174174
special = m.group(1) if m.group(1) else ''
175-
title = m.group(2) if m.group(2) else m.group(3)
175+
title = m.group(2) if m.group(2) else ''
176176
index = 0
177177
labels = None
178178
content = None

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
22
requires = [
3-
"hatchling>=0.21.1",
3+
"hatchling>=1.26",
44
]
55
build-backend = "hatchling.build"
66

‎tests/test_extensions/test_blocks/test_tab.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,3 +417,20 @@ def test_tabbed_split(self):
417417
''', # noqa: E501
418418
True
419419
)
420+
421+
def test_empty_title(self):
422+
"""Force a split of tab sets."""
423+
424+
self.check_markdown(
425+
R'''
426+
/// tab |
427+
Content
428+
///
429+
''',
430+
r'''
431+
<p>/// tab |
432+
Content
433+
///</p>
434+
''',
435+
True
436+
)

‎tests/test_extensions/test_tabbed.py‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,25 @@ def test_indented_code(self):
529529
True
530530
)
531531

532+
def test_empty_title(self):
533+
"""Test empty title."""
534+
535+
md = R"""
536+
=== ""
537+
Content
538+
"""
539+
540+
self.check_markdown(
541+
md,
542+
'''
543+
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1"></label><div class="tabbed-content">
544+
<p>Content</p>
545+
</div>
546+
</div>
547+
''', # noqa: E501
548+
True
549+
)
550+
532551

533552
class TestLegacyTabSlugs(util.MdCase):
534553
"""Test legacy tab slug cases."""
@@ -687,3 +706,22 @@ def test_header_after(self):
687706
''', # noqa: E501
688707
True
689708
)
709+
710+
def test_empty_title(self):
711+
"""Test empty title."""
712+
713+
md = R"""
714+
=== ""
715+
Content
716+
"""
717+
718+
self.check_markdown(
719+
md,
720+
'''
721+
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="_1" name="__tabbed_1" type="radio" /><label for="_1"></label><div class="tabbed-content">
722+
<p>Content</p>
723+
</div>
724+
</div>
725+
''', # noqa: E501
726+
True
727+
)

0 commit comments

Comments
 (0)