Skip to content

Commit

Permalink
Fix naming a tab as a number (Fix #24)
Browse files Browse the repository at this point in the history
  • Loading branch information
djungelorm committed Nov 5, 2018
1 parent ee8ce0e commit 1ac9a6a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ v1.1.8
* Add support for :linenos: to code tabs (#22)
* Improve fallback for non-HTML builders (#19)
* Add spelling builder to list of builders (#20)
* Fix naming a tab as a number (#24)

v1.1.7
* Fix css files not being removed when tabs are not used on a page
Expand Down
11 changes: 7 additions & 4 deletions sphinx_tabs/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ def run(self):
env = self.state.document.settings.env

args = self.content[0].strip()
try:
args = json.loads(args)
self.content.trim_start(1)
except ValueError:
if args.startswith('{'):
try:
args = json.loads(args)
self.content.trim_start(1)
except ValueError:
args = {}
else:
args = {}

tab_name = nodes.container()
Expand Down
6 changes: 6 additions & 0 deletions sphinx_tabs/test/basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@
<div class="docutils container">
Oranges</div>
</div>
<div class="item sphinx-data-tab-3 docutils container">
<div class="docutils container">
404</div>
</div>
</div>
<div class="ui bottom attached sphinx-tab tab segment sphinx-data-tab-0 active docutils container">
Apples are green, or sometimes red.</div>
<div class="ui bottom attached sphinx-tab tab segment sphinx-data-tab-1 docutils container">
Pears are green.</div>
<div class="ui bottom attached sphinx-tab tab segment sphinx-data-tab-2 docutils container">
Oranges are orange.</div>
<div class="ui bottom attached sphinx-tab tab segment sphinx-data-tab-3 docutils container">
A number in the name.</div>
</div>
4 changes: 4 additions & 0 deletions sphinx_tabs/test/basic/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
.. tab:: Oranges

Oranges are orange.

.. tab:: 404

A number in the name.

0 comments on commit 1ac9a6a

Please sign in to comment.