-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_listing_caption.py
More file actions
42 lines (37 loc) · 1.37 KB
/
test_listing_caption.py
File metadata and controls
42 lines (37 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# caption - Manage markdown captions
#
# Copyright (c) 2020-2023 flywire
# Copyright (c) 2023 sanzoghenzo
# forked from yafg - https://git.sr.ht/~ferruck/yafg
# Copyright (c) 2019 Philipp Trommler
#
# SPDX-License-Identifier: GPL-3.0-or-later
import markdown
from caption.caption import CaptionExtension
def test_listing():
in_string = """\
Listing: Simple listing test"""
expected_string = """\
<div class=listing id="_listing-1">
<figcaption><span>Listing 1:</span> Simple listing test</figcaption>
</div class=listing>"""
out_string = markdown.markdown(in_string, extensions=[CaptionExtension()])
assert out_string == expected_string
def test_listing_id_false():
in_string = """\
Listing: Simple listing test"""
expected_string = """\
<div class=listing>
<figcaption><span>Listing 1:</span> Simple listing test</figcaption>
</div class=listing>"""
out_string = markdown.markdown(in_string, extensions=[CaptionExtension(caption_id=False)])
assert out_string == expected_string
def test_listing_id_true():
in_string = """\
Listing: Simple listing test"""
expected_string = """\
<div class=listing id="_listing-1">
<figcaption><span>Listing 1:</span> Simple listing test</figcaption>
</div class=listing>"""
out_string = markdown.markdown(in_string, extensions=[CaptionExtension(caption_id=True)])
assert out_string == expected_string