Skip to content

Commit

Permalink
馃悰 Fix tab-item label with nested syntax (#135)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Sewell <chrisj_sewell@hotmail.com>
  • Loading branch information
Praecordi and chrisjsewell committed May 20, 2024
1 parent 89aaa26 commit be1b85d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/snippets/myst/tab-options.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
::::{tab-set}
:class: class-set

:::{tab-item} Label
:::{tab-item} **Label**
:name: target
:selected:
:class-container: class-container
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/rst/tab-options.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. tab-set::
:class: class-set

.. tab-item:: Label
.. tab-item:: **Label**
:name: target
:selected:
:class-container: class-container
Expand Down
2 changes: 2 additions & 0 deletions sphinx_design/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def run(self) -> list[nodes.Node]:
textnodes, _ = self.state.inline_text(self.arguments[0], self.lineno)
tab_label = nodes.rubric(
self.arguments[0],
"",
*textnodes,
classes=["sd-tab-label", *self.options.get("class-label", [])],
)
Expand Down Expand Up @@ -255,6 +256,7 @@ def run(self) -> None:

# create: <label for="id">...</label>
label_node = sd_tab_label(
"",
"",
*tab_label.children,
input_id=tab_item_identity,
Expand Down
3 changes: 2 additions & 1 deletion tests/test_snippets/snippet_post_tab-options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<container classes="sd-tab-set class-set" design_component="tab-set" is_div="True">
<sd_tab_input checked="True" id="sd-tab-item-0" set_id="sd-tab-set-0" type="radio">
<sd_tab_label classes="sd-tab-label class-label" ids="target" input_id="sd-tab-item-0">
Label
<strong>
Label
<container classes="sd-tab-content class-content" design_component="tab-content" is_div="True">
<paragraph>
Content
Expand Down
3 changes: 2 additions & 1 deletion tests/test_snippets/snippet_pre_tab-options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<container classes="sd-tab-set class-set" design_component="tab-set" is_div="True">
<container classes="sd-tab-item class-container" design_component="tab-item" is_div="True" selected="True">
<rubric classes="sd-tab-label class-label" ids="target" names="target">
Label
<strong>
Label
<container classes="sd-tab-content class-content" design_component="tab-content" is_div="True">
<paragraph>
Content
Expand Down

0 comments on commit be1b85d

Please sign in to comment.