1import nixos_render_docs as nrd
2
3from sample_md import sample1
4
5class Converter(nrd.md.Converter[nrd.asciidoc.AsciiDocRenderer]):
6 def __init__(self, manpage_urls: dict[str, str]):
7 super().__init__()
8 self._renderer = nrd.asciidoc.AsciiDocRenderer(manpage_urls)
9
10def test_lists() -> None:
11 c = Converter({})
12 # attaching to the nth ancestor list requires n newlines before the +
13 assert c._render("""\
14- a
15
16 b
17- c
18 - d
19 - e
20
21 1
22
23 f
24""") == """\
25[]
26* {empty}a
27+
28b
29
30* {empty}c
31+
32[options="compact"]
33** {empty}d
34+
35[]
36** {empty}e
37+
381
39
40
41+
42f
43"""
44
45def test_full() -> None:
46 c = Converter({ 'man(1)': 'http://example.org' })
47 assert c._render(sample1) == """\
48[WARNING]
49====
50foo
51
52[NOTE]
53=====
54nested
55=====
56
57====
58
59
60link:link[ multiline ]
61
62link:http://example.org[man(1)] reference
63
64[[b]]some [[a]]nested anchors
65
66__emph__ **strong** __nesting emph **and strong** and ``code``__
67
68[]
69* {empty}wide bullet
70
71* {empty}list
72
73
74[]
75. {empty}wide ordered
76
77. {empty}list
78
79
80[options="compact"]
81* {empty}narrow bullet
82
83* {empty}list
84
85
86[options="compact"]
87. {empty}narrow ordered
88
89. {empty}list
90
91
92[quote]
93====
94quotes
95
96[quote]
97=====
98with __nesting__
99
100----
101nested code block
102----
103=====
104
105[options="compact"]
106* {empty}and lists
107
108* {empty}
109+
110----
111containing code
112----
113
114
115and more quote
116====
117
118[start=100,options="compact"]
119. {empty}list starting at 100
120
121. {empty}goes on
122
123
124[]
125
126deflist:: {empty}
127+
128[quote]
129=====
130with a quote and stuff
131=====
132+
133----
134code block
135----
136+
137----
138fenced block
139----
140+
141text
142
143
144more stuff in same deflist:: {empty}foo
145"""