diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:24:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:24:24 +0000 |
commit | 12e8343068b906f8b2afddc5569968a8a91fa5b0 (patch) | |
tree | 75cc5e05a4392ea0292251898f992a15a16b172b /tests/test_port/test_misc.py | |
parent | Initial commit. (diff) | |
download | markdown-it-py-upstream/2.1.0.tar.xz markdown-it-py-upstream/2.1.0.zip |
Adding upstream version 2.1.0.upstream/2.1.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_port/test_misc.py')
-rw-r--r-- | tests/test_port/test_misc.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/test_port/test_misc.py b/tests/test_port/test_misc.py new file mode 100644 index 0000000..62b5bf8 --- /dev/null +++ b/tests/test_port/test_misc.py @@ -0,0 +1,44 @@ +from markdown_it import MarkdownIt, presets + + +def test_highlight_arguments(): + def highlight_func(str_, lang, attrs): + assert lang == "a" + assert attrs == "b c d" + return "<pre><code>==" + str_ + "==</code></pre>" + + conf = presets.commonmark.make() + conf["options"]["highlight"] = highlight_func + md = MarkdownIt(config=conf) + assert md.render("``` a b c d \nhl\n```") == "<pre><code>==hl\n==</code></pre>\n" + + +def test_ordered_list_info(): + def type_filter(tokens, type_): + return [t for t in tokens if t.type == type_] + + md = MarkdownIt() + + tokens = md.parse("1. Foo\n2. Bar\n20. Fuzz") + assert len(type_filter(tokens, "ordered_list_open")) == 1 + tokens = type_filter(tokens, "list_item_open") + assert len(tokens) == 3 + assert tokens[0].info == "1" + assert tokens[0].markup == "." + assert tokens[1].info == "2" + assert tokens[1].markup == "." + assert tokens[2].info == "20" + assert tokens[2].markup == "." + + tokens = md.parse(" 1. Foo\n2. Bar\n 20. Fuzz\n 199. Flp") + assert len(type_filter(tokens, "ordered_list_open")) == 1 + tokens = type_filter(tokens, "list_item_open") + assert len(tokens) == 4 + assert tokens[0].info == "1" + assert tokens[0].markup == "." + assert tokens[1].info == "2" + assert tokens[1].markup == "." + assert tokens[2].info == "20" + assert tokens[2].markup == "." + assert tokens[3].info == "199" + assert tokens[3].markup == "." |