diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:29:52 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:29:52 +0000 |
commit | fcb2f10732db61d216e2105c8154486f66b3e3ff (patch) | |
tree | efda929db4b1543eecc583e3b7d9c0bad4cd86a6 /tests/test_myst_role.py | |
parent | Initial commit. (diff) | |
download | mdit-py-plugins-fcb2f10732db61d216e2105c8154486f66b3e3ff.tar.xz mdit-py-plugins-fcb2f10732db61d216e2105c8154486f66b3e3ff.zip |
Adding upstream version 0.3.3.upstream/0.3.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_myst_role.py')
-rw-r--r-- | tests/test_myst_role.py | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/tests/test_myst_role.py b/tests/test_myst_role.py new file mode 100644 index 0000000..f70e3f8 --- /dev/null +++ b/tests/test_myst_role.py @@ -0,0 +1,89 @@ +from pathlib import Path + +from markdown_it import MarkdownIt +from markdown_it.token import Token +from markdown_it.utils import read_fixture_file +import pytest + +from mdit_py_plugins.myst_role import myst_role_plugin + +FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures", "myst_role.md") + + +def test_basic(): + md = MarkdownIt().use(myst_role_plugin) + src = "{abc}``` a ```" + tokens = md.parse(src) + print(tokens) + assert tokens == [ + Token( + type="paragraph_open", + tag="p", + nesting=1, + attrs=None, + map=[0, 1], + level=0, + children=None, + content="", + markup="", + info="", + meta={}, + block=True, + hidden=False, + ), + Token( + type="inline", + tag="", + nesting=0, + attrs=None, + map=[0, 1], + level=1, + children=[ + Token( + type="myst_role", + tag="", + nesting=0, + attrs=None, + map=None, + level=0, + children=None, + content=" a ", + markup="", + info="", + meta={"name": "abc"}, + block=False, + hidden=False, + ) + ], + content="{abc}``` a ```", + markup="", + info="", + meta={}, + block=True, + hidden=False, + ), + Token( + type="paragraph_close", + tag="p", + nesting=-1, + attrs=None, + map=None, + level=0, + children=None, + content="", + markup="", + info="", + meta={}, + block=True, + hidden=False, + ), + ] + + +@pytest.mark.parametrize("line,title,input,expected", read_fixture_file(FIXTURE_PATH)) +def test_all(line, title, input, expected): + md = MarkdownIt("commonmark").use(myst_role_plugin) + md.options["xhtmlOut"] = False + text = md.render(input) + print(text) + assert text.rstrip() == expected.rstrip() |