| 1 |
"""Test slugs.""" |
| 2 |
from .. import util |
| 3 |
import pytest |
| 4 |
from pymdownx import slugs |
| 5 |
|
| 6 |
|
| 7 |
class TestUslugify(util.MdCase): |
| 8 |
"""Test Unicode slugs.""" |
| 9 |
|
| 10 |
extension = ['markdown.extensions.toc'] |
| 11 |
extension_configs = { |
| 12 |
'markdown.extensions.toc': { |
| 13 |
"slugify": slugs.uslugify |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
def test_slug(self): |
| 18 |
"""Test the slug output.""" |
| 19 |
with pytest.warns(DeprecationWarning): |
| 20 |
self.check_markdown( |
| 21 |
r'# Testing unicode-slugs_headers ±♠Ωℑ', |
| 22 |
r'<h1 id="testing-unicode-slugs_headers-ωℑ">Testing unicode-slugs_headers ±♠Ωℑ</h1>' |
| 23 |
) |
| 24 |
|
| 25 |
|
| 26 |
class TestUslugifyEncoded(util.MdCase): |
| 27 |
"""Test Unicode encoded slugs.""" |
| 28 |
|
| 29 |
extension = ['markdown.extensions.toc'] |
| 30 |
extension_configs = { |
| 31 |
'markdown.extensions.toc': { |
| 32 |
"slugify": slugs.uslugify_encoded |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
def test_slug(self): |
| 37 |
"""Test the slug output.""" |
| 38 |
|
| 39 |
with pytest.warns(DeprecationWarning): |
| 40 |
self.check_markdown( |
| 41 |
r'# Testing unicode-slugs_headers ±♠Ωℑ with encoding', |
| 42 |
r'<h1 id="testing-unicode-slugs_headers-%CF%89%E2%84%91-with-encoding">' |
| 43 |
'Testing unicode-slugs_headers ±♠Ωℑ with encoding</h1>' |
| 44 |
) |
| 45 |
|
| 46 |
|
| 47 |
class TestUslugifyCased(util.MdCase): |
| 48 |
"""Test Unicode cased slugs.""" |
| 49 |
|
| 50 |
extension = ['markdown.extensions.toc'] |
| 51 |
extension_configs = { |
| 52 |
'markdown.extensions.toc': { |
| 53 |
"slugify": slugs.uslugify_cased |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
def test_slug(self): |
| 58 |
"""Test the slug output.""" |
| 59 |
|
| 60 |
with pytest.warns(DeprecationWarning): |
| 61 |
self.check_markdown( |
| 62 |
r'# Testing cased unicode-slugs_headers ±♠Ωℑ', |
| 63 |
r'<h1 id="Testing-cased-unicode-slugs_headers-Ωℑ">Testing cased unicode-slugs_headers ±♠Ωℑ</h1>' |
| 64 |
) |
| 65 |
|
| 66 |
|
| 67 |
class TestUslugifyCasedEncoded(util.MdCase): |
| 68 |
"""Test Unicode cased, encoded slugs.""" |
| 69 |
|
| 70 |
extension = ['markdown.extensions.toc'] |
| 71 |
extension_configs = { |
| 72 |
'markdown.extensions.toc': { |
| 73 |
"slugify": slugs.uslugify_cased_encoded |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
def test_slug(self): |
| 78 |
"""Test the slug output.""" |
| 79 |
|
| 80 |
with pytest.warns(DeprecationWarning): |
| 81 |
self.check_markdown( |
| 82 |
r'# Testing cased unicode-slugs_headers ±♠Ωℑ with encoding', |
| 83 |
r'<h1 id="Testing-cased-unicode-slugs_headers-%CE%A9%E2%84%91-with-encoding">' |
| 84 |
'Testing cased unicode-slugs_headers ±♠Ωℑ with encoding</h1>' |
| 85 |
) |
| 86 |
|
| 87 |
|
| 88 |
class TestGFM(util.MdCase): |
| 89 |
"""Test GitHub Flavored Markdown style slugs.""" |
| 90 |
|
| 91 |
extension = ['markdown.extensions.toc'] |
| 92 |
extension_configs = { |
| 93 |
'markdown.extensions.toc': { |
| 94 |
"slugify": slugs.gfm |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
def test_slug(self): |
| 99 |
"""Test the slug output.""" |
| 100 |
|
| 101 |
with pytest.warns(DeprecationWarning): |
| 102 |
self.check_markdown( |
| 103 |
r'# Testing GFM unicode-slugs_headers ±♠Ωℑ', |
| 104 |
r'<h1 id="testing-gfm-unicode-slugs_headers-Ωℑ">Testing GFM unicode-slugs_headers ±♠Ωℑ</h1>' |
| 105 |
) |
| 106 |
|
| 107 |
|
| 108 |
class TestGFMEncoded(util.MdCase): |
| 109 |
"""Test encoded GitHub Flavored Markdown style slugs.""" |
| 110 |
|
| 111 |
extension = ['markdown.extensions.toc'] |
| 112 |
extension_configs = { |
| 113 |
'markdown.extensions.toc': { |
| 114 |
"slugify": slugs.gfm_encoded |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
def test_slug(self): |
| 119 |
"""Test the slug output.""" |
| 120 |
|
| 121 |
with pytest.warns(DeprecationWarning): |
| 122 |
self.check_markdown( |
| 123 |
r'# Testing GFM unicode-slugs_headers ±♠Ωℑ with encoding', |
| 124 |
r'<h1 id="testing-gfm-unicode-slugs_headers-%CE%A9%E2%84%91-with-encoding">' |
| 125 |
r'Testing GFM unicode-slugs_headers ±♠Ωℑ with encoding</h1>' |
| 126 |
) |