Coverage for tests/test_simple_hl.py: 100%
25 statements
« prev ^ index » next coverage.py v7.6.1, created at 2026-11-30 00:03 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2026-11-30 00:03 +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><code>python hl_lines="1-3"
27 {!docs_src/simple/tutorial001.py!}</code></p>
28 """
29 )
30 )
33def test_simple_hl_include(): 1ab
34 input_md = inspect.cleandoc( 1ef
35 """
36 {* docs_src/simple/tutorial001.py hl[1:3] *}
37 """
38 )
40 result = markdown.markdown( 1ef
41 input_md,
42 extensions=[
43 IncludeVariantsExtension(),
44 IncludeExtension(),
45 ],
46 )
47 assert result == snapshot( 1ef
48 inspect.cleandoc(
49 """
50 <p>```python hl_lines="1-3"
51 print("simple line 1")
52 print("simple line 2")
53 print("simple line 3")
54 print("simple line 4")
55 print("simple line 5")
56 print("simple line 6")
57 print("simple line 7")
58 print("simple line 8")
59 print("simple line 9")
60 print("simple line 10")</p>
61 <p>```</p>
62 """
63 )
64 )
67def test_simple_hl_one(): 1ab
68 input_md = inspect.cleandoc( 1gh
69 """
70 {* docs_src/simple/tutorial001.py hl[2 ] *}
71 """
72 )
74 result = markdown.markdown( 1gh
75 input_md,
76 extensions=[
77 IncludeVariantsExtension(),
78 ],
79 )
80 assert result == snapshot( 1gh
81 inspect.cleandoc(
82 """
83 <p><code>python hl_lines="2"
84 {!docs_src/simple/tutorial001.py!}</code></p>
85 """
86 )
87 )
90def test_simple_hl_one_middle(): 1ab
91 input_md = inspect.cleandoc( 1ij
92 """
93 {* docs_src/simple/tutorial001.py hl[2,5] *}
94 """
95 )
97 result = markdown.markdown( 1ij
98 input_md,
99 extensions=[
100 IncludeVariantsExtension(),
101 ],
102 )
103 assert result == snapshot( 1ij
104 inspect.cleandoc(
105 """
106 <p><code>python hl_lines="2 5"
107 {!docs_src/simple/tutorial001.py!}</code></p>
108 """
109 )
110 )
113def test_simple_hl_one_block_middle_end(): 1ab
114 input_md = inspect.cleandoc( 1kl
115 """
116 {* docs_src/simple/tutorial001.py hl[2,5:8,10] *}
117 """
118 )
120 result = markdown.markdown( 1kl
121 input_md,
122 extensions=[
123 IncludeVariantsExtension(),
124 ],
125 )
126 assert result == snapshot( 1kl
127 inspect.cleandoc(
128 """
129 <p><code>python hl_lines="2 5-8 10"
130 {!docs_src/simple/tutorial001.py!}</code></p>
131 """
132 )
133 )