| 1 |
"""Test cases for SaneHeaders.""" |
| 2 |
from .. import util |
| 3 |
|
| 4 |
|
| 5 |
class TestSaneHeadersWithMagicLink(util.MdCase): |
| 6 |
"""Test cases for SaneHeaders and MagicLink (the motivation behind creating SaneHeaders).""" |
| 7 |
|
| 8 |
extension = [ |
| 9 |
'pymdownx.saneheaders', |
| 10 |
'pymdownx.magiclink', |
| 11 |
] |
| 12 |
|
| 13 |
extension_configs = { |
| 14 |
'pymdownx.magiclink': { |
| 15 |
'repo_url_shorthand': True, |
| 16 |
'user': 'facelessuser', |
| 17 |
'repo': 'pymdown-extensions' |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
def test_header1(self): |
| 22 |
"""Test header level 1.""" |
| 23 |
|
| 24 |
self.check_markdown( |
| 25 |
r'# Header', |
| 26 |
r'<h1>Header</h1>' |
| 27 |
) |
| 28 |
|
| 29 |
def test_header2(self): |
| 30 |
"""Test header level 2.""" |
| 31 |
|
| 32 |
self.check_markdown( |
| 33 |
r'## Header', |
| 34 |
r'<h2>Header</h2>' |
| 35 |
) |
| 36 |
|
| 37 |
def test_header3(self): |
| 38 |
"""Test header level 3.""" |
| 39 |
|
| 40 |
self.check_markdown( |
| 41 |
r'### Header', |
| 42 |
r'<h3>Header</h3>' |
| 43 |
) |
| 44 |
|
| 45 |
def test_header4(self): |
| 46 |
"""Test header level 4.""" |
| 47 |
|
| 48 |
self.check_markdown( |
| 49 |
r'#### Header', |
| 50 |
r'<h4>Header</h4>' |
| 51 |
) |
| 52 |
|
| 53 |
def test_header5(self): |
| 54 |
"""Test header level 5.""" |
| 55 |
|
| 56 |
self.check_markdown( |
| 57 |
r'##### Header', |
| 58 |
r'<h5>Header</h5>' |
| 59 |
) |
| 60 |
|
| 61 |
def test_header6(self): |
| 62 |
"""Test header level 6.""" |
| 63 |
|
| 64 |
self.check_markdown( |
| 65 |
r'###### Header', |
| 66 |
r'<h6>Header</h6>' |
| 67 |
) |
| 68 |
|
| 69 |
def test_header_trailing(self): |
| 70 |
"""Test header trailing hashes.""" |
| 71 |
|
| 72 |
self.check_markdown( |
| 73 |
r'## Header ##', |
| 74 |
r'<h2>Header</h2>' |
| 75 |
) |
| 76 |
|
| 77 |
def test_too_many_hashes(self): |
| 78 |
"""Test header with too many hashes.""" |
| 79 |
|
| 80 |
self.check_markdown( |
| 81 |
r'####### Header', |
| 82 |
r'<p>####### Header</p>' |
| 83 |
) |
| 84 |
|
| 85 |
def test_no_header(self): |
| 86 |
"""Test no header match.""" |
| 87 |
|
| 88 |
self.check_markdown( |
| 89 |
r'##Header', |
| 90 |
r'<p>##Header</p>' |
| 91 |
) |
| 92 |
|
| 93 |
def test_header_with_magiclink(self): |
| 94 |
"""Test no header match.""" |
| 95 |
|
| 96 |
self.check_markdown( |
| 97 |
r'#3', |
| 98 |
r'<p><a class="magiclink magiclink-github magiclink-issue" href="https://github.com/facelessuser/pymdown-extensions/issues/3" title="GitHub Issue: facelessuser/pymdown-extensions #3">#3</a></p>' # noqa: E501 |
| 99 |
) |