blob: 14b9f19b77eeb60a9ad1f5076726e75ede18d776 (
plain)
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
94
95
96
|
(define-module (test text-markup)
:use-module (srfi srfi-64)
:use-module (text markup))
(test-equal "Header"
" \x1b[1mHello\x1b[m \n"
(sxml->ansi-text
'(header (@ (width 20))
"Hello")))
(test-equal "Center"
" . "
(sxml->ansi-text
'(center (@ (width 11)) ".")))
(test-equal "Bold is NOT restored after a nested italic"
"\x1b[1mbold\x1b[3mitalic\x1b[mafter\x1b[m"
(sxml->ansi-text '(b (group "bold" (i "italic") "after"))))
(test-equal "hr"
" ──────────────────────────────────────────────────────────── \n"
(sxml->ansi-text '(hr)))
(test-group "Description list"
(test-equal
(string-append
" key │ value\n"
"key 2 │ value 2\n")
(sxml->ansi-text '(dl (dt "key")
(dd "value")
(dt "key 2")
(dd "value 2"))))
(test-equal "Muliple dt to one dd"
(string-append
" key │ value\n"
"key 2 │ \n"
" key │ value\n")
(sxml->ansi-text '(dl (dt "key")
(dt "key 2")
(dd "value")
(dt "key")
(dd "value"))))
(test-equal "Muliple dd to one dt"
(string-append
" key │ value\n"
" │ value 2\n"
"key 2 │ \n")
(sxml->ansi-text '(dl (dt "key")
(dd "value")
(dd "value 2")
(dt "key 2")))))
(test-equal "Scheme block"
"(sxml->ansi-text
'(dl (dt \"key\")
(dd \"value\")
(dd \"value 2\")
(dt \"key 2\")))"
(sxml->ansi-text
'(scheme (sxml->ansi-text '(dl (dt "key")
(dd "value")
(dd "value 2")
(dt "key 2"))))))
(test-equal "Unknown tag"
"\x1b[1m??`\x1b[7m(\"Hello, \" (b \"nested\") \"after\")\x1b[m'\n"
(sxml->ansi-text '(block (err "Hello, " (b "nested") "after")
(br))))
(test-equal "Empty document"
""
(sxml->ansi-text '()))
(test-equal "Paragraph text flowing + nested format"
;; This also shows bad spacing
;; second line is longer that the expected line width.
"A sentance \x1b[1mcontaining\x1b[m the word
pneumonoultramicroscopicsilicovolcanoconiosis
is rather hard to justify properly
"
(sxml->ansi-text
'(p (@ (width 40)) "A sentance " (b "containing") " the word pneumonoultramicroscopicsilicovolcanoconiosis is rather hard to justify properly")))
(test-equal "blockquote"
" Hello
-- Hugo
" (sxml->ansi-text '(blockquote "Hello" (br) "-- Hugo")))
'((text markup))
|