diff options
author | Waylan Limberg <waylan@gmail.com> | 2011-07-14 10:29:19 -0400 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2011-07-14 10:29:19 -0400 |
commit | be3627f5b1f3a7df806a899337a74648edfef76a (patch) | |
tree | 1405af7c32fcaf49b3cdccf417907333f7441f98 | |
parent | bc277a0c0bf4866f9384e9bd33add438fdc13d9c (diff) | |
download | markdown-be3627f5b1f3a7df806a899337a74648edfef76a.tar.gz markdown-be3627f5b1f3a7df806a899337a74648edfef76a.tar.bz2 markdown-be3627f5b1f3a7df806a899337a74648edfef76a.zip |
Updated toc extension's anchorlink option to work properly with recent refactor.
-rw-r--r-- | markdown/extensions/toc.py | 8 |
1 files 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) |