Skip to content

Commit

Permalink
Un-smart-quote footnote back refs
Browse files Browse the repository at this point in the history
  • Loading branch information
symroe committed Dec 10, 2018
1 parent 2369d36 commit dbf847d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/markdown2.py
Expand Up @@ -1981,6 +1981,12 @@ def _do_smart_punctuation(self, text):
text = text.replace("...", "…")
text = text.replace(" . . . ", "…")
text = text.replace(". . .", "…")

if "footnotes" in self.extras and "footnote-ref" in text:
# Quotes in the footnote back ref get converted to "smart" quotes
# Change them back here to ensure they work.
text = text.replace("footnote-ref”", "footnote-ref\"")

return text

_block_quote_base = r'''
Expand Down
14 changes: 14 additions & 0 deletions test/tm-cases/footnotes_smarty-pants.html
@@ -0,0 +1,14 @@
<p>This is a para with a footnote.<sup class="footnote-ref" id="fnref-1"><a href="#fn-1">1</a></sup></p>

<div class="footnotes">
<hr />
<ol>
<li id="fn-1">
<p>Here is the <em>body</em> of <span class="yo">the</span> footnote.</p>

<div class="blah">And here is the second para of the footnote.</div>

<p><a href="#fnref-1" class="footnoteBackLink" title="Jump back to footnote 1 in the text.">&#8617;</a></p>
</li>
</ol>
</div>
1 change: 1 addition & 0 deletions test/tm-cases/footnotes_smarty-pants.opts
@@ -0,0 +1 @@
{"extras": ["footnotes", "smarty-pants"]}
5 changes: 5 additions & 0 deletions test/tm-cases/footnotes_smarty-pants.text
@@ -0,0 +1,5 @@
This is a para with a footnote.[^1]

[^1]: Here is the <em>body</em> of <span class="yo">the</span> footnote.

<div class="blah">And here is the second para of the footnote.</div>

0 comments on commit dbf847d

Please sign in to comment.