blob: d808c5b50c345b1fb693760e2213ed44e9b0566b (
plain) (
blame)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
import nixos_render_docs as nrd
from sample_md import sample1
from typing import Mapping
class Converter(nrd.md.Converter[nrd.commonmark.CommonMarkRenderer]):
def __init__(self, manpage_urls: Mapping[str, str]):
super().__init__()
self._renderer = nrd.commonmark.CommonMarkRenderer(manpage_urls)
# NOTE: in these tests we represent trailing spaces by ` ` and replace them with real space later,
# since a number of editors will strip trailing whitespace on save and that would break the tests.
def test_indented_fence() -> None:
c = Converter({})
s = """\
> - ```foo
> thing
>
> rest
> ```\
""".replace(' ', ' ')
assert c._render(s) == s
def test_full() -> None:
c = Converter({ 'man(1)': 'http://example.org' })
assert c._render(sample1) == """\
**Warning:** foo
**Note:** nested
[
multiline
](link)
[` man(1) `](http://example.org) reference
some nested anchors
*emph* **strong** *nesting emph **and strong** and ` code `*
- wide bullet
- list
1. wide ordered
2. list
- narrow bullet
- list
1. narrow ordered
2. list
> quotes
>
> > with *nesting*
> >
> > ```
> > nested code block
> > ```
>
> - and lists
> - ```
> containing code
> ```
>
> and more quote
100. list starting at 100
101. goes on
- *deflist*
> with a quote
> and stuff
```
code block
```
```
fenced block
```
text
- *more stuff in same deflist*
foo""".replace(' ', ' ')
|