aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortim <tdixon51793@gmail.com>2011-12-20 03:50:19 -0600
committertim <tdixon51793@gmail.com>2011-12-20 04:17:41 -0600
commit7393f58c14d8dad6194c4845d545a3d7f7ccbf2e (patch)
tree2a04a130837ee11f4f25a48878df54eb2b4cfba2
parent2e3830b9bf3a0829db7a5d04f731b5019d28cc65 (diff)
downloadmarkdown-7393f58c14d8dad6194c4845d545a3d7f7ccbf2e.tar.gz
markdown-7393f58c14d8dad6194c4845d545a3d7f7ccbf2e.tar.bz2
markdown-7393f58c14d8dad6194c4845d545a3d7f7ccbf2e.zip
New footnotes configuration option: BACKLINK_TEXT (second try).
BACKLINK_TEXT specifies the text that's used in the link at the end of the footnote to link back up to the reader's place. It still defaults to "&#8617;". Okay, so at first I had an uncessarily complicated commit for this and submitted a pull request. Waylan showed me a better way to do it, here: https://github.com/startling/Python-Markdown/commit/ee7d1a26c76f970c12226ca48ba52dc1d32f2488#markdown/extensions/footnotes.py-P19 So I made another commit and added it to the pull request. But then I accidentally added yet another commit to the pull request, accidentally. Since then, I've realized it would be best to start with a new branch and closed that first pull request. Hopefully this will be the last try.
-rw-r--r--markdown/extensions/footnotes.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py
index d05edda..a4c897b 100644
--- a/markdown/extensions/footnotes.py
+++ b/markdown/extensions/footnotes.py
@@ -43,7 +43,11 @@ class FootnoteExtension(markdown.Extension):
'UNIQUE_IDS':
[False,
"Avoid name collisions across "
- "multiple calls to reset()."]}
+ "multiple calls to reset()."],
+ "BACKLINK_TEXT":
+ ["&#8617;",
+ "The text string that links from the footnote to the reader's place."]
+ }
for key, value in configs:
self.config[key][0] = value
@@ -282,10 +286,12 @@ class FootnoteTreeprocessor(markdown.treeprocessors.Treeprocessor):
class FootnotePostprocessor(markdown.postprocessors.Postprocessor):
""" Replace placeholders with html entities. """
+ def __init__(self, footnotes):
+ self.footnotes = footnotes
def run(self, text):
text = text.replace(FN_BACKLINK_TEXT, "&#8617;")
- return text.replace(NBSP_PLACEHOLDER, "&#160;")
+ return text.replace(NBSP_PLACEHOLDER, self.footnotes.getConfig("BACKLINK_TEXT"))
def makeExtension(configs=[]):
""" Return an instance of the FootnoteExtension """