From dbf847d5c4246dfad8ddbd5a13e3ea3423860b38 Mon Sep 17 00:00:00 2001 From: Sym Roe Date: Mon, 10 Dec 2018 16:32:38 +0000 Subject: [PATCH] Un-smart-quote footnote back refs Refs #150 --- lib/markdown2.py | 6 ++++++ test/tm-cases/footnotes_smarty-pants.html | 14 ++++++++++++++ test/tm-cases/footnotes_smarty-pants.opts | 1 + test/tm-cases/footnotes_smarty-pants.text | 5 +++++ 4 files changed, 26 insertions(+) create mode 100644 test/tm-cases/footnotes_smarty-pants.html create mode 100644 test/tm-cases/footnotes_smarty-pants.opts create mode 100644 test/tm-cases/footnotes_smarty-pants.text diff --git a/lib/markdown2.py b/lib/markdown2.py index f64f5551..6e96b9fb 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -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''' diff --git a/test/tm-cases/footnotes_smarty-pants.html b/test/tm-cases/footnotes_smarty-pants.html new file mode 100644 index 00000000..b48e23a6 --- /dev/null +++ b/test/tm-cases/footnotes_smarty-pants.html @@ -0,0 +1,14 @@ +

This is a para with a footnote.1

+ +
+
+
    +
  1. +

    Here is the body of the footnote.

    + +
    And here is the second para of the footnote.
    + +

    +
  2. +
+
diff --git a/test/tm-cases/footnotes_smarty-pants.opts b/test/tm-cases/footnotes_smarty-pants.opts new file mode 100644 index 00000000..2deeb86d --- /dev/null +++ b/test/tm-cases/footnotes_smarty-pants.opts @@ -0,0 +1 @@ +{"extras": ["footnotes", "smarty-pants"]} diff --git a/test/tm-cases/footnotes_smarty-pants.text b/test/tm-cases/footnotes_smarty-pants.text new file mode 100644 index 00000000..27470d1e --- /dev/null +++ b/test/tm-cases/footnotes_smarty-pants.text @@ -0,0 +1,5 @@ +This is a para with a footnote.[^1] + +[^1]: Here is the body of the footnote. + +
And here is the second para of the footnote.