From d00929830ca9618baa56f2d3c2a3f161db3e240e Mon Sep 17 00:00:00 2001 From: Larivact Date: Thu, 11 Aug 2016 21:12:51 +0200 Subject: [PATCH 1/2] remove unnecessary postprocessor If I am not mistaken it's redundant. --- markdown/extensions/footnotes.py | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py index b52815f3c..fcd19dc15 100644 --- a/markdown/extensions/footnotes.py +++ b/markdown/extensions/footnotes.py @@ -24,8 +24,6 @@ from ..odict import OrderedDict import re -FN_BACKLINK_TEXT = "zz1337820767766393qq" -NBSP_PLACEHOLDER = "qq3936677670287331zz" DEF_RE = re.compile(r'[ ]{0,3}\[\^([^\]]*)\]:\s*(.*)') TABBED_RE = re.compile(r'((\t)|( ))(.*)') @@ -76,10 +74,6 @@ def extendMarkdown(self, md, md_globals): md.treeprocessors.add( "footnote", FootnoteTreeprocessor(self), "_begin" ) - # Insert a postprocessor after amp_substitute oricessor - md.postprocessors.add( - "footnote", FootnotePostprocessor(self), ">amp_substitute" - ) def reset(self): """ Clear footnotes on reset, and prepare for distinct document. """ @@ -153,12 +147,12 @@ def makeFootnotesDiv(self, root): "Jump back to footnote %d in the text" % (self.footnotes.index(id)+1) ) - backlink.text = FN_BACKLINK_TEXT + backlink.text = self.getConfig("BACKLINK_TEXT") if li.getchildren(): node = li[-1] if node.tag == "p": - node.text = node.text + NBSP_PLACEHOLDER + node.text = node.text + " " node.append(backlink) else: p = etree.SubElement(li, "p") @@ -304,18 +298,6 @@ def run(self, root): root.append(footnotesDiv) -class FootnotePostprocessor(Postprocessor): - """ Replace placeholders with html entities. """ - def __init__(self, footnotes): - self.footnotes = footnotes - - def run(self, text): - text = text.replace( - FN_BACKLINK_TEXT, self.footnotes.getConfig("BACKLINK_TEXT") - ) - return text.replace(NBSP_PLACEHOLDER, " ") - - def makeExtension(*args, **kwargs): """ Return an instance of the FootnoteExtension """ return FootnoteExtension(*args, **kwargs) From 0342ef96f2a4ea72519ba2191adbc0e9994cb7c4 Mon Sep 17 00:00:00 2001 From: Larivact Date: Thu, 11 Aug 2016 21:25:54 +0200 Subject: [PATCH 2/2] remove unused import --- markdown/extensions/footnotes.py | 1 - 1 file changed, 1 deletion(-) diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py index fcd19dc15..635a2aec4 100644 --- a/markdown/extensions/footnotes.py +++ b/markdown/extensions/footnotes.py @@ -19,7 +19,6 @@ from ..preprocessors import Preprocessor from ..inlinepatterns import Pattern from ..treeprocessors import Treeprocessor -from ..postprocessors import Postprocessor from ..util import etree, text_type from ..odict import OrderedDict import re