-
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SmartSymbols in TOC tokens (#2327)
Also move legacy tests to move tests
- Loading branch information
1 parent
8f5283f
commit 1270c86
Showing
9 changed files
with
148 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
tests/extensions/smartsymbols/smartsymbols (with smarty).html
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
"""Test cases for SmartSymbols.""" | ||
from .. import util | ||
import markdown | ||
|
||
|
||
class TestSmartSymbols(util.MdCase): | ||
"""Test smart symbols works in various scenarios.""" | ||
|
||
extension = [ | ||
'toc', | ||
'smarty', | ||
'pymdownx.smartsymbols' | ||
] | ||
extension_configs = {} | ||
|
||
def test_copyright(self): | ||
"""Test copyright.""" | ||
|
||
self.check_markdown( | ||
'Copyright (c)', | ||
'<p>Copyright ©</p>' | ||
) | ||
|
||
def test_trademark(self): | ||
"""Test trademark.""" | ||
|
||
self.check_markdown( | ||
'Trademark(tm)', | ||
'<p>Trademark™</p>' | ||
) | ||
|
||
def test_registered(self): | ||
"""Test registered.""" | ||
|
||
self.check_markdown( | ||
'Registered(r)', | ||
'<p>Registered®</p>' | ||
) | ||
|
||
def test_plus_minus(self): | ||
"""Test plus/minus.""" | ||
|
||
self.check_markdown( | ||
'230 +/- 10% V', | ||
'<p>230 ± 10% V</p>' | ||
) | ||
|
||
def test_neq(self): | ||
"""Test not equal.""" | ||
|
||
self.check_markdown( | ||
'A =/= B', | ||
'<p>A ≠ B</p>' | ||
) | ||
|
||
def test_right(self): | ||
"""Test right arrow.""" | ||
|
||
self.check_markdown( | ||
'right arrow -->', | ||
'<p>right arrow →</p>' | ||
) | ||
|
||
def test_left(self): | ||
"""Test left arrow.""" | ||
|
||
self.check_markdown( | ||
'left arrow <--', | ||
'<p>left arrow ←</p>' | ||
) | ||
|
||
def test_double_arrow(self): | ||
"""Test double arrow.""" | ||
|
||
self.check_markdown( | ||
'double arrow <-->', | ||
'<p>double arrow ↔</p>' | ||
) | ||
|
||
def test_ordinals(self): | ||
"""Test ordinals.""" | ||
|
||
self.check_markdown( | ||
""" | ||
Good: 1st 2nd 3rd 11th 12th 13th 15th 32nd 103rd | ||
Bad: 1th 2th 3th 2rd 1nd 22th 33th 41nd 53nd | ||
""", | ||
""" | ||
<p>Good: 1<sup>st</sup> 2<sup>nd</sup> 3<sup>rd</sup> 11<sup>th</sup> 12<sup>th</sup> 13<sup>th</sup> 15<sup>th</sup> 32<sup>nd</sup> 103<sup>rd</sup></p> | ||
<p>Bad: 1th 2th 3th 2rd 1nd 22th 33th 41nd 53nd</p> | ||
""", # noqa: E501 | ||
True | ||
) | ||
|
||
def test_fractions(self): | ||
"""Test fractions.""" | ||
|
||
self.check_markdown( | ||
""" | ||
Fraction 1/2 | ||
Fraction 1/4 | ||
Fraction 3/4 | ||
Fraction 1/3 | ||
Fraction 2/3 | ||
Fraction 1/5 | ||
Fraction 2/5 | ||
Fraction 3/5 | ||
Fraction 4/5 | ||
Fraction 1/6 | ||
Fraction 5/6 | ||
Fraction 1/8 | ||
Fraction 3/8 | ||
Fraction 5/8 | ||
Fraction 7/8 | ||
""", | ||
""" | ||
<p>Fraction ½ | ||
Fraction ¼ | ||
Fraction ¾ | ||
Fraction ⅓ | ||
Fraction ⅔ | ||
Fraction ⅕ | ||
Fraction ⅖ | ||
Fraction ⅗ | ||
Fraction ⅘ | ||
Fraction ⅙ | ||
Fraction ⅚ | ||
Fraction ⅛ | ||
Fraction ⅜ | ||
Fraction ⅝ | ||
Fraction ⅞</p> | ||
""", | ||
True | ||
) | ||
|
||
def test_toc_tokens(self): | ||
"""Ensure smart symbols end up correctly in table of content tokens.""" | ||
|
||
md = markdown.Markdown(extensions=['toc', 'pymdownx.smartsymbols']) | ||
md.convert('# *Foo* =/= `bar`') | ||
self.assertEqual(md.toc_tokens, [{'level': 1, 'id': 'foo-bar', 'name': 'Foo ≠ bar', 'children': []}]) |