blob: 96d506d182344376555cbe044cf58992e283ccc6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
from markdown_it import MarkdownIt
def test_token_levels():
mdit = MarkdownIt(options_update={"linkify": True}).enable("linkify")
tokens = mdit.parse("www.python.org")
inline = tokens[1]
assert inline.type == "inline"
link_open = inline.children[0]
assert link_open.type == "link_open"
link_text = inline.children[1]
assert link_text.type == "text"
link_close = inline.children[2]
assert link_close.type == "link_close"
# Assert that linkify tokens have correct nesting levels
assert link_open.level == 0
assert link_text.level == 1
assert link_close.level == 0
|