diff options
Diffstat (limited to '')
-rw-r--r-- | tests/test_substitution.py | 33 | ||||
-rw-r--r-- | tests/test_substitution/test_tokens.yml | 105 |
2 files changed, 138 insertions, 0 deletions
diff --git a/tests/test_substitution.py b/tests/test_substitution.py new file mode 100644 index 0000000..706c1e2 --- /dev/null +++ b/tests/test_substitution.py @@ -0,0 +1,33 @@ +from pathlib import Path +from textwrap import dedent + +from markdown_it import MarkdownIt +from markdown_it.utils import read_fixture_file +import pytest + +# from markdown_it.token import Token +from mdit_py_plugins.substitution import substitution_plugin + +FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures", "substitution.md") + + +@pytest.mark.parametrize("line,title,input,expected", read_fixture_file(FIXTURE_PATH)) +def test_fixtures(line, title, input, expected): + md = MarkdownIt("commonmark").enable("table").use(substitution_plugin) + text = md.render(input) + print(text) + assert text.rstrip() == expected.rstrip() + + +def test_tokens(data_regression): + md = MarkdownIt().use(substitution_plugin) + tokens = md.parse( + dedent( + """\ + {{ block }} + + a {{ inline }} b + """ + ) + ) + data_regression.check([t.as_dict() for t in tokens]) diff --git a/tests/test_substitution/test_tokens.yml b/tests/test_substitution/test_tokens.yml new file mode 100644 index 0000000..a3179d2 --- /dev/null +++ b/tests/test_substitution/test_tokens.yml @@ -0,0 +1,105 @@ +- attrs: + - - class + - substitution + - - text + - block + block: true + children: null + content: block + hidden: false + info: '' + level: 0 + map: + - 0 + - 1 + markup: '{}' + meta: {} + nesting: 0 + tag: div + type: substitution_block +- attrs: null + block: true + children: null + content: '' + hidden: false + info: '' + level: 0 + map: + - 2 + - 3 + markup: '' + meta: {} + nesting: 1 + tag: p + type: paragraph_open +- attrs: null + block: true + children: + - attrs: null + block: false + children: null + content: 'a ' + hidden: false + info: '' + level: 0 + map: null + markup: '' + meta: {} + nesting: 0 + tag: '' + type: text + - attrs: + - - class + - substitution + - - text + - inline + block: false + children: null + content: inline + hidden: false + info: '' + level: 0 + map: null + markup: '{}' + meta: {} + nesting: 0 + tag: span + type: substitution_inline + - attrs: null + block: false + children: null + content: ' b' + hidden: false + info: '' + level: 0 + map: null + markup: '' + meta: {} + nesting: 0 + tag: '' + type: text + content: a {{ inline }} b + hidden: false + info: '' + level: 1 + map: + - 2 + - 3 + markup: '' + meta: {} + nesting: 0 + tag: '' + type: inline +- attrs: null + block: true + children: null + content: '' + hidden: false + info: '' + level: 0 + map: null + markup: '' + meta: {} + nesting: -1 + tag: p + type: paragraph_close |