File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ def iterparent(self, root):
23
23
yield parent , child
24
24
25
25
def run (self , doc ):
26
+ marker_found = False
27
+
26
28
div = etree .Element ("div" )
27
29
div .attrib ["class" ] = "toc"
28
30
last_li = None
@@ -61,6 +63,7 @@ def run(self, doc):
61
63
if p [i ] == c :
62
64
p [i ] = div
63
65
break
66
+ marker_found = True
64
67
65
68
if header_rgx .match (c .tag ):
66
69
tag_level = int (c .tag [- 1 ])
@@ -106,6 +109,14 @@ def run(self, doc):
106
109
c .append (anchor )
107
110
108
111
list_stack [- 1 ].append (last_li )
112
+ if not marker_found :
113
+ # searialize and attach to markdown instance.
114
+ prettify = self .markdown .treeprocessors .get ('prettify' )
115
+ if prettify : prettify .run (div )
116
+ toc = self .markdown .serializer (div )
117
+ for pp in self .markdown .postprocessors .values ():
118
+ toc = pp .run (toc )
119
+ self .markdown .toc = toc
109
120
110
121
class TocExtension (markdown .Extension ):
111
122
def __init__ (self , configs ):
You can’t perform that action at this time.
0 commit comments