Skip to content

Commit 5ad00fa

Browse files
committed
Always add toc to Markdown Class Instance
Previously, we only added the toc attribute (md.toc) if no Marker was found within the document. However, that has caused framworks to do things like force insert a marker, run convert, then extract the toc from the body of the document. This is much cleaner. And if the user wants to add the toc to the document also, they still can.
1 parent 52b9f8c commit 5ad00fa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

markdown/extensions/toc.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@ def run(self, doc):
200200
prettify = self.markdown.treeprocessors.get('prettify')
201201
if prettify:
202202
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
203+
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
209209

210210

211211
class TocExtension(Extension):

0 commit comments

Comments
 (0)