@@ -536,90 +536,6 @@ def testHeaderInlineMarkup(self):
536536 {'level' : 1 , 'id' : 'some-header-with-markup' , 'name' : 'Some Header with markup.' , 'children' : []},
537537 ])
538538
539- def testAnchorLink (self ):
540- """ Test TOC Anchorlink. """
541- md = markdown .Markdown (
542- extensions = [markdown .extensions .toc .TocExtension (anchorlink = True )]
543- )
544- text = '# Header 1\n \n ## Header *2*'
545- self .assertEqual (
546- md .convert (text ),
547- '<h1 id="header-1"><a class="toclink" href="#header-1">Header 1</a></h1>\n '
548- '<h2 id="header-2"><a class="toclink" href="#header-2">Header <em>2</em></a></h2>'
549- )
550-
551- def testAnchorLinkWithSingleInlineCode (self ):
552- """ Test TOC Anchorlink with single inline code. """
553- md = markdown .Markdown (
554- extensions = [markdown .extensions .toc .TocExtension (anchorlink = True )]
555- )
556- text = '# This is `code`.'
557- self .assertEqual (
558- md .convert (text ),
559- '<h1 id="this-is-code">' # noqa
560- '<a class="toclink" href="#this-is-code">' # noqa
561- 'This is <code>code</code>.' # noqa
562- '</a>' # noqa
563- '</h1>' # noqa
564- )
565-
566- def testAnchorLinkWithDoubleInlineCode (self ):
567- """ Test TOC Anchorlink with double inline code. """
568- md = markdown .Markdown (
569- extensions = [markdown .extensions .toc .TocExtension (anchorlink = True )]
570- )
571- text = '# This is `code` and `this` too.'
572- self .assertEqual (
573- md .convert (text ),
574- '<h1 id="this-is-code-and-this-too">' # noqa
575- '<a class="toclink" href="#this-is-code-and-this-too">' # noqa
576- 'This is <code>code</code> and <code>this</code> too.' # noqa
577- '</a>' # noqa
578- '</h1>' # noqa
579- )
580-
581- def testPermalink (self ):
582- """ Test TOC Permalink. """
583- md = markdown .Markdown (
584- extensions = [markdown .extensions .toc .TocExtension (permalink = True )]
585- )
586- text = '# Header'
587- self .assertEqual (
588- md .convert (text ),
589- '<h1 id="header">' # noqa
590- 'Header' # noqa
591- '<a class="headerlink" href="#header" title="Permanent link">¶</a>' # noqa
592- '</h1>' # noqa
593- )
594-
595- def testPermalinkWithSingleInlineCode (self ):
596- """ Test TOC Permalink with single inline code. """
597- md = markdown .Markdown (
598- extensions = [markdown .extensions .toc .TocExtension (permalink = True )]
599- )
600- text = '# This is `code`.'
601- self .assertEqual (
602- md .convert (text ),
603- '<h1 id="this-is-code">' # noqa
604- 'This is <code>code</code>.' # noqa
605- '<a class="headerlink" href="#this-is-code" title="Permanent link">¶</a>' # noqa
606- '</h1>' # noqa
607- )
608-
609- def testPermalinkWithDoubleInlineCode (self ):
610- """ Test TOC Permalink with double inline code. """
611- md = markdown .Markdown (
612- extensions = [markdown .extensions .toc .TocExtension (permalink = True )]
613- )
614- text = '# This is `code` and `this` too.'
615- self .assertEqual (
616- md .convert (text ),
617- '<h1 id="this-is-code-and-this-too">' # noqa
618- 'This is <code>code</code> and <code>this</code> too.' # noqa
619- '<a class="headerlink" href="#this-is-code-and-this-too" title="Permanent link">¶</a>' # noqa
620- '</h1>' # noqa
621- )
622-
623539 def testTitle (self ):
624540 """ Test TOC Title. """
625541 md = markdown .Markdown (
@@ -714,115 +630,6 @@ def testTocInHeaders(self):
714630 '<h1 id="toc"><em>[TOC]</em></h1>' # noqa
715631 )
716632
717- def testMinMaxLevel (self ):
718- """ Test toc_height setting """
719- md = markdown .Markdown (
720- extensions = [markdown .extensions .toc .TocExtension (toc_depth = '3-4' )]
721- )
722- text = '# Header 1 not in TOC\n \n ## Header 2 not in TOC\n \n ### Header 3\n \n ####Header 4'
723- self .assertEqual (
724- md .convert (text ),
725- '<h1>Header 1 not in TOC</h1>\n '
726- '<h2>Header 2 not in TOC</h2>\n '
727- '<h3 id="header-3">Header 3</h3>\n '
728- '<h4 id="header-4">Header 4</h4>'
729- )
730- self .assertEqual (
731- md .toc ,
732- '<div class="toc">\n '
733- '<ul>\n ' # noqa
734- '<li><a href="#header-3">Header 3</a>' # noqa
735- '<ul>\n ' # noqa
736- '<li><a href="#header-4">Header 4</a></li>\n ' # noqa
737- '</ul>\n ' # noqa
738- '</li>\n ' # noqa
739- '</ul>\n ' # noqa
740- '</div>\n '
741- )
742-
743- self .assertNotIn ("Header 1" , md .toc )
744-
745- def testMaxLevel (self ):
746- """ Test toc_depth setting """
747- md = markdown .Markdown (
748- extensions = [markdown .extensions .toc .TocExtension (toc_depth = 2 )]
749- )
750- text = '# Header 1\n \n ## Header 2\n \n ###Header 3 not in TOC'
751- self .assertEqual (
752- md .convert (text ),
753- '<h1 id="header-1">Header 1</h1>\n '
754- '<h2 id="header-2">Header 2</h2>\n '
755- '<h3>Header 3 not in TOC</h3>'
756- )
757- self .assertEqual (
758- md .toc ,
759- '<div class="toc">\n '
760- '<ul>\n ' # noqa
761- '<li><a href="#header-1">Header 1</a>' # noqa
762- '<ul>\n ' # noqa
763- '<li><a href="#header-2">Header 2</a></li>\n ' # noqa
764- '</ul>\n ' # noqa
765- '</li>\n ' # noqa
766- '</ul>\n ' # noqa
767- '</div>\n '
768- )
769-
770- self .assertNotIn ("Header 3" , md .toc )
771-
772- def testMinMaxLevelwithBaseLevel (self ):
773- """ Test toc_height setting together with baselevel """
774- md = markdown .Markdown (
775- extensions = [markdown .extensions .toc .TocExtension (toc_depth = '4-6' ,
776- baselevel = 3 )]
777- )
778- text = '# First Header\n \n ## Second Level\n \n ### Third Level'
779- self .assertEqual (
780- md .convert (text ),
781- '<h3>First Header</h3>\n '
782- '<h4 id="second-level">Second Level</h4>\n '
783- '<h5 id="third-level">Third Level</h5>'
784- )
785- self .assertEqual (
786- md .toc ,
787- '<div class="toc">\n '
788- '<ul>\n ' # noqa
789- '<li><a href="#second-level">Second Level</a>' # noqa
790- '<ul>\n ' # noqa
791- '<li><a href="#third-level">Third Level</a></li>\n ' # noqa
792- '</ul>\n ' # noqa
793- '</li>\n ' # noqa
794- '</ul>\n ' # noqa
795- '</div>\n '
796- )
797- self .assertNotIn ("First Header" , md .toc )
798-
799- def testMaxLevelwithBaseLevel (self ):
800- """ Test toc_depth setting together with baselevel """
801- md = markdown .Markdown (
802- extensions = [markdown .extensions .toc .TocExtension (toc_depth = 3 ,
803- baselevel = 2 )]
804- )
805- text = '# Some Header\n \n ## Next Level\n \n ### Too High'
806- self .assertEqual (
807- md .convert (text ),
808- '<h2 id="some-header">Some Header</h2>\n '
809- '<h3 id="next-level">Next Level</h3>\n '
810- '<h4>Too High</h4>'
811- )
812- self .assertEqual (
813- md .toc ,
814- '<div class="toc">\n '
815- '<ul>\n ' # noqa
816- '<li><a href="#some-header">Some Header</a>' # noqa
817- '<ul>\n ' # noqa
818- '<li><a href="#next-level">Next Level</a></li>\n ' # noqa
819- '</ul>\n ' # noqa
820- '</li>\n ' # noqa
821- '</ul>\n ' # noqa
822- '</div>\n '
823- )
824- self .assertNotIn ("Too High" , md .toc )
825-
826633
827634class TestSmarty (unittest .TestCase ):
828635 def setUp (self ):
0 commit comments