Skip to content

Commit 7f809b6

Browse files
Add tests for superscript plugin
Fixtures file is copied from the `markdown-it-sup` tests: https://github.com/markdown-it/markdown-it-sup/blob/master/test/fixtures/sup.txt Test is modelled on other Markdown-It-Py inline tests.
1 parent e0dc45c commit 7f809b6

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

tests/fixtures/superscript.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.
2+
^test^
3+
.
4+
<p><sup>test</sup></p>
5+
.
6+
7+
.
8+
^foo\^
9+
.
10+
<p>^foo^</p>
11+
.
12+
13+
.
14+
2^4 + 3^5
15+
.
16+
<p>2^4 + 3^5</p>
17+
.
18+
19+
.
20+
^foo~bar^baz^bar~foo^
21+
.
22+
<p><sup>foo~bar</sup>baz<sup>bar~foo</sup></p>
23+
.
24+
25+
.
26+
^\ foo\ ^
27+
.
28+
<p><sup> foo </sup></p>
29+
.
30+
31+
.
32+
^foo\\\\\\\ bar^
33+
.
34+
<p><sup>foo\\\ bar</sup></p>
35+
.
36+
37+
.
38+
^foo\\\\\\ bar^
39+
.
40+
<p>^foo\\\ bar^</p>
41+
.
42+
43+
.
44+
**^foo^ bar**
45+
.
46+
<p><strong><sup>foo</sup> bar</strong></p>
47+
.
48+

tests/test_superscript.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from pathlib import Path
2+
3+
from markdown_it import MarkdownIt
4+
from markdown_it.utils import read_fixture_file
5+
import pytest
6+
7+
from mdit_py_plugins.superscript import superscript_plugin
8+
9+
FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures")
10+
11+
12+
@pytest.mark.parametrize(
13+
"line,title,input,expected",
14+
read_fixture_file(FIXTURE_PATH.joinpath("superscript.md")),
15+
)
16+
def test_superscript_fixtures(line, title, input, expected):
17+
md = MarkdownIt("commonmark").use(superscript_plugin)
18+
if "DISABLE-CODEBLOCKS" in title:
19+
md.disable("code")
20+
md.options["xhtmlOut"] = False
21+
text = md.render(input)
22+
print(text)
23+
assert text.rstrip() == expected.rstrip()

0 commit comments

Comments
 (0)