Coverage for tests/test_simple_hl.py: 100%
25 statements
« prev ^ index » next coverage.py v7.6.1, created at 2026-10-15 15:22 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2026-10-15 15:22 +0000
1import inspect 1ab
3import markdown 1ab
4from inline_snapshot import snapshot 1ab
5from mdx_include.mdx_include import IncludeExtension 1ab
7from markdown_include_variants import IncludeVariantsExtension 1ab
10def test_simple_hl(): 1ab
11 input_md = inspect.cleandoc( 1cd
12 """
13 {* docs_src/simple/tutorial001.py hl[1:3] *}
14 """
15 )
17 result = markdown.markdown( 1cd
18 input_md,
19 extensions=[
20 IncludeVariantsExtension(),
21 ],
22 )
23 assert result == snapshot( 1cd
24 inspect.cleandoc(
25 """
26 <p>//// tab | Python 3.8+
27 <code>python hl_lines="1-3"
28 {!docs_src/simple/tutorial001.py!}</code></p>
29 <p>////</p>
30 """
31 )
32 )
35def test_simple_hl_include(): 1ab
36 input_md = inspect.cleandoc( 1ef
37 """
38 {* docs_src/simple/tutorial001.py hl[1:3] *}
39 """
40 )
42 result = markdown.markdown( 1ef
43 input_md,
44 extensions=[
45 IncludeVariantsExtension(),
46 IncludeExtension(),
47 ],
48 )
49 assert result == snapshot( 1ef
50 inspect.cleandoc(
51 """
52 <p>//// tab | Python 3.8+
53 ```python hl_lines="1-3"
54 print("simple line 1")
55 print("simple line 2")
56 print("simple line 3")
57 print("simple line 4")
58 print("simple line 5")
59 print("simple line 6")
60 print("simple line 7")
61 print("simple line 8")
62 print("simple line 9")
63 print("simple line 10")</p>
64 <p>```</p>
65 <p>////</p>
66 """
67 )
68 )
71def test_simple_hl_one(): 1ab
72 input_md = inspect.cleandoc( 1gh
73 """
74 {* docs_src/simple/tutorial001.py hl[2 ] *}
75 """
76 )
78 result = markdown.markdown( 1gh
79 input_md,
80 extensions=[
81 IncludeVariantsExtension(),
82 ],
83 )
84 assert result == snapshot( 1gh
85 inspect.cleandoc(
86 """
87 <p>//// tab | Python 3.8+
88 <code>python hl_lines="2"
89 {!docs_src/simple/tutorial001.py!}</code></p>
90 <p>////</p>
91 """
92 )
93 )
96def test_simple_hl_one_middle(): 1ab
97 input_md = inspect.cleandoc( 1ij
98 """
99 {* docs_src/simple/tutorial001.py hl[2,5] *}
100 """
101 )
103 result = markdown.markdown( 1ij
104 input_md,
105 extensions=[
106 IncludeVariantsExtension(),
107 ],
108 )
109 assert result == snapshot( 1ij
110 inspect.cleandoc(
111 """
112 <p>//// tab | Python 3.8+
113 <code>python hl_lines="2 5"
114 {!docs_src/simple/tutorial001.py!}</code></p>
115 <p>////</p>
116 """
117 )
118 )
121def test_simple_hl_one_block_middle_end(): 1ab
122 input_md = inspect.cleandoc( 1kl
123 """
124 {* docs_src/simple/tutorial001.py hl[2,5:8,10] *}
125 """
126 )
128 result = markdown.markdown( 1kl
129 input_md,
130 extensions=[
131 IncludeVariantsExtension(),
132 ],
133 )
134 assert result == snapshot( 1kl
135 inspect.cleandoc(
136 """
137 <p>//// tab | Python 3.8+
138 <code>python hl_lines="2 5-8 10"
139 {!docs_src/simple/tutorial001.py!}</code></p>
140 <p>////</p>
141 """
142 )
143 )