Skip to content

MkTabbedBlocks

Show source on GitHub

PyMdown Block Extension Tab.

Example: Regular

Jinja

{{ {"Tab 1": "Some markdown", "Tab 2": "Other Markdown"} | MkTabbedBlocks}}

Python

MkTabbedBlocks(tabs=[...])

Some markdown

Other Markdown

/// tab | Tab 1
    new: True

Some markdown
///

/// tab | Tab 2

Other Markdown
///
<div class="tabbed-set" data-tabs="1:2"><input checked id="__tabbed_1_1" name="__tabbed_1" type="radio"><label for="__tabbed_1_1">Tab 1</label><div class="tabbed-content">
<p>Some markdown</p>
</div>
<input id="__tabbed_1_2" name="__tabbed_1" type="radio"><label for="__tabbed_1_2">Tab 2</label><div class="tabbed-content">
<p>Other Markdown</p>
</div>
</div>
MkTabbedBlocks
├── MkTabBlock('Some markdown', 'Tab 1', new=True, select=False)
│   ╰── MkText('Some markdown')
╰── MkTabBlock('Other Markdown', 'Tab 2', new=False, select=False)
    ╰── MkText('Other Markdown')

Example: Nested

Jinja

{% set node = {"Tab 1": "Some markdown", "Tab 2": "Other Markdown"} | MkTabbedBlocks %}
{{ {"Tabs": node, "Admonition": mk.MkAdmonition("Nested admonition")} | MkTabbedBlocks }}

Python

MkContainer([...])

Some markdown

Other Markdown

Info

Nested admonition

Some markdown

Other Markdown

Info

Nested admonition

/// tab | Tab 1
    new: True

Some markdown
///

/// tab | Tab 2

Other Markdown
///


!!! info
    Nested admonition


/// tab | Tabs
    new: True

/// tab | Tab 1
    new: True

Some markdown
///

/// tab | Tab 2

Other Markdown
///
///

/// tab | Admonition

!!! info
    Nested admonition
///
<div class="tabbed-set" data-tabs="1:2"><input checked id="__tabbed_1_1" name="__tabbed_1" type="radio"><label for="__tabbed_1_1">Tab 1</label><div class="tabbed-content">
<p>Some markdown</p>
</div>
<input id="__tabbed_1_2" name="__tabbed_1" type="radio"><label for="__tabbed_1_2">Tab 2</label><div class="tabbed-content">
<p>Other Markdown</p>
</div>
</div>
<div class="admonition info">
<p class="admonition-title">Info</p>
<p>Nested admonition</p>
</div>
<div class="tabbed-set" data-tabs="2:2"><input checked id="__tabbed_2_1" name="__tabbed_2" type="radio"><label for="__tabbed_2_1">Tabs</label><div class="tabbed-content">
<div class="tabbed-set" data-tabs="3:1"><input checked id="__tabbed_3_1" name="__tabbed_3" type="radio"><label for="__tabbed_3_1">Tab 1</label><div class="tabbed-content">
<p>Some markdown</p>
<div class="tabbed-set" data-tabs="4:1"><input checked id="__tabbed_4_1" name="__tabbed_4" type="radio"><label for="__tabbed_4_1">Tab 2</label><div class="tabbed-content">
<p>Other Markdown</p>
</div>
</div>
</div>
</div>
</div>
<input id="__tabbed_2_2" name="__tabbed_2" type="radio"><label for="__tabbed_2_2">Admonition</label><div class="tabbed-content">
<div class="admonition info">
<p class="admonition-title">Info</p>
<p>Nested admonition</p>
</div>
</div>
</div>
MkContainer
├── MkTabbedBlocks(tabs=[...])
│   ├── MkTabBlock('Some markdown', 'Tab 1', new=True, select=False)
│   │   ╰── MkText('Some markdown')
│   ╰── MkTabBlock('Other Markdown', 'Tab 2', new=False, select=False)
│       ╰── MkText('Other Markdown')
├── MkAdmonition('Nested admonition')
│   ╰── MkText('Nested admonition')
╰── MkTabbedBlocks(tabs=[...])
    ├── MkTabBlock([list([...])], 'Tabs', new=True, select=False)
├── MkTabbedBlocks(tabs=[...])
│   ├── MkTabBlock('Some markdown', 'Tab 1', new=True, select=False)
│   │   ╰── MkText('Some markdown')
│   ╰── MkTabBlock('Other Markdown', 'Tab 2', new=False, select=False)
│       ╰── MkText('Other Markdown')
│   ╰── MkTabBlock([list([...])], 'Admonition', new=False, select=False)
├── MkAdmonition('Nested admonition')
│   ╰── MkText('Nested admonition')

Bases: MkTabContainer

Name Children Inherits
MkTabContainer
mknodes.basenodes.mktabcontainer
Base class for nodes containing tabs.
graph TD
  94721311949312["mktabbedblocks.MkTabbedBlocks"]
  94721311947536["mktabcontainer.MkTabContainer"]
  94721311697232["mkcontainer.MkContainer"]
  94721308848336["mknode.MkNode"]
  94721311766592["node.Node"]
  140564252373184["builtins.object"]
  94721311947536 --> 94721311949312
  94721311697232 --> 94721311947536
  94721308848336 --> 94721311697232
  94721311766592 --> 94721308848336
  140564252373184 --> 94721311766592
/home/runner/work/mknodes/mknodes/mknodes/basenodes/mktabbedblocks/metadata.toml
[metadata]
name = "MkTabbedBlocks"
icon = "mdi:tab"

[requirements.extension."pymdownx.blocks.tab"]

[examples.regular]
title = "Regular"
jinja = """
{{ {"Tab 1": "Some markdown", "Tab 2": "Other Markdown"} | MkTabbedBlocks}}
"""

[examples.nested]
title = "Nested"
jinja = """
{% set node = {"Tab 1": "Some markdown", "Tab 2": "Other Markdown"} | MkTabbedBlocks %}
{{ {"Tabs": node, "Admonition": mk.MkAdmonition("Nested admonition")} | MkTabbedBlocks }}
"""

[fragments.tab]
template = """
{{ node.fence_boundary }} tab | {{ node.title }}
{{ node.attributes_block }}

{{ node.content_block }}{{ node.fence_boundary }}

"""

[output.markdown]
template = """
{{ node.items | join(node.block_separator) }}
"""
mknodes.basenodes.mktabbedblocks.MkTabbedBlocks
class MkTabbedBlocks(mktabcontainer.MkTabContainer):
    """PyMdown Block Extension Tab."""

    items: list[mktabs.MkTabBlock]
    REQUIRED_EXTENSIONS = [resources.Extension("pymdownx.blocks.tab")]
    Tab = mktabs.MkTabBlock