From 7942471746b5ab0ce20182e26a23f4432632e2e5 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Mon, 2 Aug 2010 22:26:41 -0400 Subject: Fix Ticket 68. Remove an old line of code from the footnote extension that should have been removed excatly 2 years and 3 days ago (commit bd185087dc899b6157f8) when elementtree support was added. And to think it has been generating an error the whole time and was only just reported now. It appears this was never tested as it still does not work after removing the old line. At least we do not get an error. The footnote placeholder is just an empty paragraph. Thanks for the report Evan Carmi. --- markdown/extensions/footnotes.py | 1 - 1 file changed, 1 deletion(-) diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py index f9e5101..3c9d23a 100644 --- a/markdown/extensions/footnotes.py +++ b/markdown/extensions/footnotes.py @@ -291,7 +291,6 @@ class FootnoteTreeprocessor(markdown.treeprocessors.Treeprocessor): ind = element.getchildren().find(child) element.getchildren().insert(ind + 1, footnotesDiv) child.tail = None - fnPlaceholder.parent.replaceChild(fnPlaceholder, footnotesDiv) else: root.append(footnotesDiv) -- cgit v1.2.3 From f039ca04cccf0645a21cb0739c17e5f6abd593fb Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Mon, 2 Aug 2010 23:36:39 -0400 Subject: 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. --- markdown/extensions/footnotes.py | 15 +++++++-------- tests/extensions/extra/footnote_placeholder.html | 10 ++++++++++ tests/extensions/extra/footnote_placeholder.txt | 5 +++++ 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 tests/extensions/extra/footnote_placeholder.html create mode 100644 tests/extensions/extra/footnote_placeholder.txt 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) diff --git a/tests/extensions/extra/footnote_placeholder.html b/tests/extensions/extra/footnote_placeholder.html new file mode 100644 index 0000000..7aaf4b2 --- /dev/null +++ b/tests/extensions/extra/footnote_placeholder.html @@ -0,0 +1,10 @@ +
+
+
    +
  1. +

    A Footnote. + 

    +
  2. +
+
+

Some text with a footnote1.

\ No newline at end of file diff --git a/tests/extensions/extra/footnote_placeholder.txt b/tests/extensions/extra/footnote_placeholder.txt new file mode 100644 index 0000000..0b0af42 --- /dev/null +++ b/tests/extensions/extra/footnote_placeholder.txt @@ -0,0 +1,5 @@ +///Footnotes Go Here/// + +Some text with a footnote[^1]. + +[^1]: A Footnote. -- cgit v1.2.3 From 3bd36d4c8f0ca1f7345999a58d7b8c2f5e6f9fbe Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Tue, 3 Aug 2010 00:14:22 -0400 Subject: Fixed ticket 69. Corrected a few syntax incompatabilities between python 2.x and 3.x in the setup script. Now the script actually can run 2to3 automaticaly when run under Python 3.x. Thanks for the report Virgil Dupras. --- setup.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index a0292eb..21249c3 100755 --- a/setup.py +++ b/setup.py @@ -34,9 +34,10 @@ class md_install_scripts(install_scripts): f = file(bat_path, 'w') f.write(bat_str) f.close() - print 'Created:', bat_path - except Exception, e: - print 'ERROR: Unable to create %s: %s' % (bat_path, e) + print ('Created: %s' % bat_path) + except Exception: + _, err, _ = sys.exc_info() # for both 2.x & 3.x compatability + print ('ERROR: Unable to create %s: %s' % (bat_path, err)) data = dict( name = 'Markdown', -- cgit v1.2.3