"""Test cases for Tabbed (alternative style).""" from .. import util from pymdownx.slugs import slugify class TestTab(util.MdCase): """Test tab cases.""" extension = ['pymdownx.tabbed', 'pymdownx.superfences', 'markdown.extensions.def_list', 'pymdownx.details'] extension_configs = {'pymdownx.tabbed': {'alternate_style': True}} def test_with_preceding_text(self): """Test content directly before tabs.""" expected = r'''

foo foo

''' # noqa: E501 self.check_markdown( r''' foo **foo** === "Tab" ''', expected, True ) def test_tabbed(self): """Test tabbed.""" self.check_markdown( r''' === "Tab" Some *content* And more `content`. === "Another Tab" Some more content. ``` code ``` ''', r'''

Some content

And more content.

Some more content.

code
            
''', # noqa: E501 True ) def test_tabbed_markdown_title(self): """Test tabbed.""" self.check_markdown( r''' === "**Tab**" Some *content* And more `content`. === "_Another Tab_" Some more content. ``` code ``` ''', r'''

Some content

And more content.

Some more content.

code
            
''', # noqa: E501 True ) def test_nested_tabbed(self): """Test nested tabbed.""" self.check_markdown( r''' === "Tab" Some *content* === "Tab A" - item 1 - item 2 === "Tab B" - item A - item B === "Another Tab" Some more content. ''', r'''

Some content

  • item 1

  • item 2

  • item A

  • item B

Some more content.

''', # noqa: E501 True ) def test_tabbed_split(self): """Force a split of tab sets.""" self.check_markdown( r''' === "Tab" Some *content* And more `content`. ===! "Another Tab" Some more content. ``` code ``` ''', r'''

Some content

And more content.

Some more content.

code
            
''', # noqa: E501 True ) def test_tabbed_break(self): """Test that tabs are properly terminated on blocks that are not under the tab.""" self.check_markdown( r''' === "Tab" Some *content* And more `content`. Content ''', r'''

Some content

And more content.

Content

''', # noqa: E501 True ) def test_tabbed_select(self): """Test selecting a tab.""" self.check_markdown( r''' === "Tab 1" content ===+ "Tab 2" content === "Tab 3" content ''', r'''

content

content

content

''', # noqa: E501 True ) def test_tabbed_select_multiple(self): """Test selecting multiple tabs.""" self.check_markdown( r''' === "Tab 1" content ===+ "Tab 2" content ===+ "Tab 3" content ''', r'''

content

content

content

''', # noqa: E501 True ) def test_with_lists(self): """Test with lists.""" self.check_markdown( ''' - List === "Tab" - Paragraph Paragraph ''', ''' ''', # noqa: E501 True ) def test_with_big_lists(self): """Test details with a longer list.""" self.check_markdown( ''' - List === "Tab" - Paragraph Paragraph - Paragraph paragraph ''', ''' ''', # noqa: E501 True ) def test_with_complex_lists(self): """Test details in a complex list scenario.""" self.check_markdown( ''' - List === "Tab" - Paragraph === "Tab" 1. Paragraph Paragraph ''', ''' ''', # noqa: E501 True ) def test_definition_list(self): """Test with definition list.""" self.check_markdown( ''' - List === "Tab" Term : Definition More text : Another definition Even more text ''', ''' ''', # noqa: E501 True ) def test_with_details(self): """Test with definition list.""" self.check_markdown( ''' === "Output" ???+ note "Open styled details" ??? danger "Nested details!" And more content again. ''', '''
Open styled details
Nested details!

And more content again.

''', # noqa: E501 True ) def test_tabbed_complex_list(self): """Test tabbed complex list scenario.""" self.check_markdown( ''' === "Tab with loose lists" - Parent 1 - Child 1 - Child 2 ''', '''
  • Parent 1

    • Child 1
    • Child 2
''', # noqa: E501 True ) def test_tabbed_complex_list_unindented_content(self): """Test tabbed complex list scenario with un-indented content.""" self.check_markdown( ''' === "Tab with loose lists" - Parent 1 - Child 1 - Child 2 - Parent 2 ''', '''
  • Parent 1

    • Child 1
    • Child 2
''', # noqa: E501 True ) def test_indented_code(self): """Test indented code.""" md = """ === "Tab 1" code """ self.check_markdown( md, '''
code
            
''', # noqa: E501 True ) class TestLegacyTabSlugs(util.MdCase): """Test legacy tab slug cases.""" extension = ['pymdownx.tabbed', 'toc'] extension_configs = {'pymdownx.tabbed': {'slugify': slugify(case='lower'), 'alternate_style': True}} MD = """ ### Here is some text === "Here is some text" content === "Here is some text" content """ def test_tab_slugs(self): """Test tab slugs.""" self.check_markdown( self.MD, '''

Here is some text

content

content

''', # noqa: E501 True ) class TestLegacyTabSlugsSep(util.MdCase): """Test legacy tab slug separator cases.""" extension = ['pymdownx.tabbed', 'toc'] extension_configs = { 'pymdownx.tabbed': {'slugify': slugify(case='lower'), 'separator': '_', 'alternate_style': True} } MD = """ ### Here is some text === "Here is some text" content === "Here is some text" content """ def test_slug_with_separator(self): """Test tab slugs with separator.""" self.check_markdown( self.MD, '''

Here is some text

content

content

''', # noqa: E501 True ) class TestTabSlugsCombineHeader(util.MdCase): """Combine header slug with content tab.""" extension = ['pymdownx.tabbed', 'toc', 'pymdownx.details'] extension_configs = { 'pymdownx.tabbed': { 'slugify': slugify(case='lower'), 'combine_header_slug': True, 'alternate_style': True } } def test_combine_header_slug(self): """Test that slugs are a combination of the header slug and the tab title.""" md = R""" ### Here is some text === "First Tab" content ### Another header ??? "title" === "Second Tab" content """ self.check_markdown( md, '''

Here is some text

content

Another header

title

content

''', # noqa: E501 True ) def test_no_header(self): """Test when there is no header.""" md = R""" === "A Tab" content """ self.check_markdown( md, '''

content

''', # noqa: E501 True ) def test_header_after(self): """Test when header comes after.""" md = R""" === "A Tab" content # Header """ self.check_markdown( md, '''

content

Header

''', # noqa: E501 True )