@@ -59,7 +59,7 @@ def order_toc_list(toc_list):
5959 for p in reversed (parents ):
6060 if current_level <= p ['level' ]:
6161 to_pop += 1
62- else :
62+ else : # pragma: no cover
6363 break
6464 if to_pop :
6565 levels = levels [:- to_pop ]
@@ -153,7 +153,6 @@ def run(self, doc):
153153 used_ids .add (c .attrib ["id" ])
154154
155155 toc_list = []
156- marker_found = False
157156 for (p , c ) in self .iterparent (doc ):
158157 text = '' .join (itertext (c )).strip ()
159158 if not text :
@@ -171,7 +170,6 @@ def run(self, doc):
171170 if p [i ] == c :
172171 p [i ] = div
173172 break
174- marker_found = True
175173
176174 if header_rgx .match (c .tag ):
177175
@@ -200,12 +198,12 @@ def run(self, doc):
200198 prettify = self .markdown .treeprocessors .get ('prettify' )
201199 if prettify :
202200 prettify .run (div )
203- if not marker_found :
204- # serialize and attach to markdown instance.
205- toc = self .markdown .serializer (div )
206- for pp in self .markdown .postprocessors .values ():
207- toc = pp .run (toc )
208- self .markdown .toc = toc
201+
202+ # serialize and attach to markdown instance.
203+ toc = self .markdown .serializer (div )
204+ for pp in self .markdown .postprocessors .values ():
205+ toc = pp .run (toc )
206+ self .markdown .toc = toc
209207
210208
211209class TocExtension (Extension ):
@@ -223,12 +221,12 @@ def __init__(self, *args, **kwargs):
223221 "title" : ["" ,
224222 "Title to insert into TOC <div> - "
225223 "Defaults to an empty string" ],
226- "anchorlink" : [0 ,
227- "1 if header should be a self link - "
228- "Defaults to 0 " ],
224+ "anchorlink" : [False ,
225+ "True if header should be a self link - "
226+ "Defaults to False " ],
229227 "permalink" : [0 ,
230- "1 or link text if a Sphinx-style permalink should "
231- "be added - Defaults to 0 " ]
228+ "True or link text if a Sphinx-style permalink should "
229+ "be added - Defaults to False " ]
232230 }
233231
234232 super (TocExtension , self ).__init__ (* args , ** kwargs )
0 commit comments