"""Test slugs."""
from .. import util
from pymdownx import slugs
class TestUslugify(util.MdCase):
"""Test Unicode slugs."""
extension = ['markdown.extensions.toc']
extension_configs = {
'markdown.extensions.toc': {
"slugify": slugs.slugify(case="lower")
}
}
def test_slug(self):
"""Test the slug output."""
self.check_markdown(
r'# Testing unicode-slugs_headers ±♠Ωℑ',
r'
'
)
class TestUslugifyEncoded(util.MdCase):
"""Test Unicode encoded slugs."""
extension = ['markdown.extensions.toc']
extension_configs = {
'markdown.extensions.toc': {
"slugify": slugs.slugify(case="lower", percent_encode=True)
}
}
def test_slug(self):
"""Test the slug output."""
self.check_markdown(
r'# Testing unicode-slugs_headers ±♠Ωℑ with encoding',
r''
)
class TestUslugifyCased(util.MdCase):
"""Test Unicode cased slugs."""
extension = ['markdown.extensions.toc']
extension_configs = {
'markdown.extensions.toc': {
"slugify": slugs.slugify()
}
}
def test_slug(self):
"""Test the slug output."""
self.check_markdown(
r'# Testing cased unicode-slugs_headers ±♠Ωℑ',
r''
)
class TestUslugifyCasedEncoded(util.MdCase):
"""Test Unicode cased, encoded slugs."""
extension = ['markdown.extensions.toc']
extension_configs = {
'markdown.extensions.toc': {
"slugify": slugs.slugify(percent_encode=True)
}
}
def test_slug(self):
"""Test the slug output."""
self.check_markdown(
r'# Testing cased unicode-slugs_headers ±♠Ωℑ with encoding',
r''
)
class TestGFM(util.MdCase):
"""Test GitHub Flavored Markdown style slugs."""
extension = ['markdown.extensions.toc']
extension_configs = {
'markdown.extensions.toc': {
"slugify": slugs.slugify(case="lower-ascii")
}
}
def test_slug(self):
"""Test the slug output."""
self.check_markdown(
r'# Testing GFM unicode-slugs_headers ±♠Ωℑ',
r''
)
class TestGFMEncoded(util.MdCase):
"""Test encoded GitHub Flavored Markdown style slugs."""
extension = ['markdown.extensions.toc']
extension_configs = {
'markdown.extensions.toc': {
"slugify": slugs.slugify(case="lower-ascii", percent_encode=True)
}
}
def test_slug(self):
"""Test the slug output."""
self.check_markdown(
r'# Testing GFM unicode-slugs_headers ±♠Ωℑ with encoding',
r''
)
class TestNormalize(util.MdCase):
"""Test different normalization methods."""
extension = ['markdown.extensions.toc']
extension_configs = {
'markdown.extensions.toc': {
"slugify": slugs.slugify(normalize='NFD')
}
}
def test_slug(self):
"""Test the slug output."""
self.check_markdown(
r'# Théâtre',
r'Théâtre
'
)
class TestFold(util.MdCase):
"""Test different normalization methods."""
extension = ['markdown.extensions.toc']
extension_configs = {
'markdown.extensions.toc': {
"slugify": slugs.slugify(case='fold')
}
}
def test_slug(self):
"""Test the slug output."""
self.check_markdown(
r'# ß',
r'ß
'
)