From 8e5fed5123ccd34a17ae6c72aa8e529f11341c10 Mon Sep 17 00:00:00 2001 From: Crozzers Date: Sat, 7 Dec 2024 18:01:05 +0000 Subject: [PATCH] Fix smarty pants extra not triggering when it should --- CHANGES.md | 1 + lib/markdown2.py | 8 +++++++- test/tm-cases/smarty_pants_issue611.html | 3 +++ test/tm-cases/smarty_pants_issue611.opts | 1 + test/tm-cases/smarty_pants_issue611.text | 3 +++ 5 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/tm-cases/smarty_pants_issue611.html create mode 100644 test/tm-cases/smarty_pants_issue611.opts create mode 100644 test/tm-cases/smarty_pants_issue611.text diff --git a/CHANGES.md b/CHANGES.md index fca4b40f..bf264626 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ - [pull #605] Add support for Python 3.13, drop EOL 3.8 - [pull #607] Fix `middle-word-em` extra preventing strongs from being recognized (#606) - [pull #609] Add option to output to file in CLI (#608) +- [pull #613] Fix smarty pants extra not triggering when it should (#611) ## python-markdown2 2.5.1 diff --git a/lib/markdown2.py b/lib/markdown2.py index aec13cb8..6f66c9bd 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -3314,7 +3314,13 @@ def run(self, text): return text def test(self, text): - return "'" in text or '"' in text + return any(i in text for i in ( + "'", + '"', + '--', + '...', + '. . .' + )) class Strike(Extra): diff --git a/test/tm-cases/smarty_pants_issue611.html b/test/tm-cases/smarty_pants_issue611.html new file mode 100644 index 00000000..b926e73d --- /dev/null +++ b/test/tm-cases/smarty_pants_issue611.html @@ -0,0 +1,3 @@ +

ho ho — ho ho

+ +

ho “ho” — ho ho

diff --git a/test/tm-cases/smarty_pants_issue611.opts b/test/tm-cases/smarty_pants_issue611.opts new file mode 100644 index 00000000..d0390c68 --- /dev/null +++ b/test/tm-cases/smarty_pants_issue611.opts @@ -0,0 +1 @@ +{"extras": ["smarty-pants"]} diff --git a/test/tm-cases/smarty_pants_issue611.text b/test/tm-cases/smarty_pants_issue611.text new file mode 100644 index 00000000..d0ec3d27 --- /dev/null +++ b/test/tm-cases/smarty_pants_issue611.text @@ -0,0 +1,3 @@ +ho ho --- ho ho + +ho "ho" --- ho ho \ No newline at end of file