diff options
author | Waylan Limberg <waylan@gmail.com> | 2010-08-02 23:36:39 -0400 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2010-08-02 23:36:39 -0400 |
commit | f039ca04cccf0645a21cb0739c17e5f6abd593fb (patch) | |
tree | d5f7d7bf2e1bb480048eee80eef20e451495f488 /markdown/extensions/footnotes.py | |
parent | 7942471746b5ab0ce20182e26a23f4432632e2e5 (diff) | |
download | markdown-f039ca04cccf0645a21cb0739c17e5f6abd593fb.tar.gz markdown-f039ca04cccf0645a21cb0739c17e5f6abd593fb.tar.bz2 markdown-f039ca04cccf0645a21cb0739c17e5f6abd593fb.zip |
Fixed problem hidden by Ticket 68. Defining a footnote placeholder in a markdown document results in the placeholder actually being replaced. Also added a test for this. Note that if the placeholder paragraph has other text, that text is lost. Not sure if this is a bug or bad markdown syntax.
Diffstat (limited to 'markdown/extensions/footnotes.py')
-rw-r--r-- | markdown/extensions/footnotes.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py index 3c9d23a..2bdabe9 100644 --- a/markdown/extensions/footnotes.py +++ b/markdown/extensions/footnotes.py @@ -84,10 +84,10 @@ class FootnoteExtension(markdown.Extension): for child in element: if child.text: if child.text.find(self.getConfig("PLACE_MARKER")) > -1: - return child, True + return child, element, True if child.tail: if child.tail.find(self.getConfig("PLACE_MARKER")) > -1: - return (child, element), False + return child, element, False finder(child) return None @@ -282,14 +282,13 @@ class FootnoteTreeprocessor(markdown.treeprocessors.Treeprocessor): if footnotesDiv: result = self.footnotes.findFootnotesPlaceholder(root) if result: - node, isText = result + child, parent, isText = result + ind = parent.getchildren().index(child) if isText: - node.text = None - node.getchildren().insert(0, footnotesDiv) + parent.remove(child) + parent.insert(ind, footnotesDiv) else: - child, element = node - ind = element.getchildren().find(child) - element.getchildren().insert(ind + 1, footnotesDiv) + parent.insert(ind + 1, footnotesDiv) child.tail = None else: root.append(footnotesDiv) |