Skip to content

Commit 1ac9a6a

Browse files
committed
Fix naming a tab as a number (Fix #24)
1 parent ee8ce0e commit 1ac9a6a

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ v1.1.8
22
* Add support for :linenos: to code tabs (#22)
33
* Improve fallback for non-HTML builders (#19)
44
* Add spelling builder to list of builders (#20)
5+
* Fix naming a tab as a number (#24)
56

67
v1.1.7
78
* Fix css files not being removed when tabs are not used on a page

sphinx_tabs/tabs.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,13 @@ def run(self):
9090
env = self.state.document.settings.env
9191

9292
args = self.content[0].strip()
93-
try:
94-
args = json.loads(args)
95-
self.content.trim_start(1)
96-
except ValueError:
93+
if args.startswith('{'):
94+
try:
95+
args = json.loads(args)
96+
self.content.trim_start(1)
97+
except ValueError:
98+
args = {}
99+
else:
97100
args = {}
98101

99102
tab_name = nodes.container()

sphinx_tabs/test/basic/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@
1212
<div class="docutils container">
1313
Oranges</div>
1414
</div>
15+
<div class="item sphinx-data-tab-3 docutils container">
16+
<div class="docutils container">
17+
404</div>
18+
</div>
1519
</div>
1620
<div class="ui bottom attached sphinx-tab tab segment sphinx-data-tab-0 active docutils container">
1721
Apples are green, or sometimes red.</div>
1822
<div class="ui bottom attached sphinx-tab tab segment sphinx-data-tab-1 docutils container">
1923
Pears are green.</div>
2024
<div class="ui bottom attached sphinx-tab tab segment sphinx-data-tab-2 docutils container">
2125
Oranges are orange.</div>
26+
<div class="ui bottom attached sphinx-tab tab segment sphinx-data-tab-3 docutils container">
27+
A number in the name.</div>
2228
</div>

sphinx_tabs/test/basic/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@
1111
.. tab:: Oranges
1212

1313
Oranges are orange.
14+
15+
.. tab:: 404
16+
17+
A number in the name.

0 commit comments

Comments
 (0)