From be3627f5b1f3a7df806a899337a74648edfef76a Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Thu, 14 Jul 2011 10:29:19 -0400 Subject: Updated toc extension's anchorlink option to work properly with recent refactor. --- markdown/extensions/toc.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/markdown/extensions/toc.py b/markdown/extensions/toc.py index ce0cd8d..2fa5ce1 100644 --- a/markdown/extensions/toc.py +++ b/markdown/extensions/toc.py @@ -95,11 +95,15 @@ class TocTreeprocessor(markdown.treeprocessors.Treeprocessor): link.attrib["href"] = '#' + id if int(self.config["anchorlink"]): - anchor = etree.SubElement(c, "a") - anchor.text = text + anchor = etree.Element("a") + anchor.text = c.text anchor.attrib["href"] = "#" + id anchor.attrib["class"] = "toclink" c.text = "" + for elem in c.getchildren(): + anchor.append(elem) + c.remove(elem) + c.append(anchor) list_stack[-1].append(last_li) -- cgit v1.2.3