Skip to content

Commit 9f60de2

Browse files
committed
Update/add discount library tests
1 parent a80e7b7 commit 9f60de2

19 files changed

+628
-132
lines changed

discount/Plan9/markdown.2

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ tags from the output.
122122
Suppress Smartypants-style replacement of quotes, dashes, or ellipses.
123123
.TP
124124
.B MKD_STRICT
125-
Disable superscript and relaxed emphasis processing if configured; otherwise a no-op.
125+
Disable superscript and relaxed emphasis processing.
126126
.TP
127127
.B MKD_TAGTEXT
128128
Process as inside an

discount/Plan9/markdown.6

+1-3
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,7 @@ cell in the column.
520520
A colon at both ends of a column's header dashes indicates center alignment.
521521
.TP
522522
Relaxed Emphasis
523-
If configured with
524-
.BR --relaxed-emphasis ,
525-
the rules for emphasis are changed so that a single
523+
The rules for emphasis are changed so that a single
526524
.B _
527525
will not count as an emphasis character in the middle of a word.
528526
This is useful for documenting some code where

discount/Plan9/mkfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ BIN=/$objtype/bin
22
CC='cc -D_BSD_EXTENSION -D_C99_SNPRINTF_EXTENSION'
33

44
markdown:
5-
ape/psh -c 'cd .. && make'
5+
ape/psh -c 'cd .. && $CC mktags.c -o mktags && ./mktags > blocktags && make'
66

77
none:V: markdown
88

discount/tests/backslash.t

+5
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,10 @@ try -fautolink 'autolink url with trailing \' \
1212
'http://a.com/\' \
1313
'<p><a href="http://a.com/\">http://a.com/\</a></p>'
1414
15+
16+
try 'backslashes before <text' '\<code>' '<p>\<code></p>'
17+
try 'backslashes before <{EOF}' '\<' '<p>&lt;</p>'
18+
try 'backslashes before <[space]' '\< j' '<p>&lt; j</p>'
19+
1520
summary $0
1621
exit $rc

discount/tests/code.t

+108-8
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,54 @@ try 'backslashes in code(1)' ' printf "%s: \n", $1;' \
3131
try 'backslashes in code(2)' '`printf "%s: \n", $1;`' \
3232
'<p><code>printf "%s: \n", $1;</code></p>'
3333

34-
if ./markdown -V | grep FENCED-CODE >/dev/null; then
34+
try 'fenced code disabled backtick' \
35+
'```
3536
36-
try 'fenced code block' \
37+
unrecognized code!
38+
```' \
39+
'<p>```</p>
40+
41+
<p>unrecognized code!
42+
```</p>'
43+
44+
# no <pre/> proves it’s the inline variant of `code` delimitation
45+
try 'fenced code disabled backtick as inline code' \
46+
'```
47+
inline code?
48+
```' \
49+
'<p><code>
50+
inline code?
51+
</code></p>'
52+
53+
try 'fenced code disabled tilde' \
54+
'~~~
55+
56+
unrecognized code!
57+
~~~' \
58+
'<p>~~~</p>
59+
60+
<p>unrecognized code!
61+
~~~</p>'
62+
63+
try -ffencedcode 'fenced code block with blank lines' \
3764
'~~~
3865
code!
66+
67+
still code!
3968
~~~' \
4069
'<pre><code>code!
70+
71+
still code!
4172
</code></pre>'
4273

43-
try 'fenced code block in list' \
74+
try -ffencedcode 'fenced code block' \
75+
'~~~
76+
code!
77+
~~~' \
78+
'<pre><code>code!
79+
</code></pre>'
80+
81+
try -ffencedcode 'fenced code block in list' \
4482
'1. ~~~
4583
code block
4684
~~~' \
@@ -49,20 +87,20 @@ code block
4987
</code></pre></li>
5088
</ol>'
5189

52-
try 'fenced code block in blockquote' \
90+
try -ffencedcode 'fenced code block in blockquote' \
5391
'>~~~
5492
code
5593
~~~' \
5694
'<blockquote><pre><code>code
5795
</code></pre></blockquote>'
5896

59-
try 'unterminated fenced code block' \
97+
try -ffencedcode 'unterminated fenced code block' \
6098
'~~~
6199
code' \
62100
'<p>~~~
63101
code</p>'
64102

65-
try 'fenced code block with tildes' \
103+
try -ffencedcode 'fenced code block with tildes' \
66104
'~~~~~
67105
~~~
68106
code with tildes
@@ -73,7 +111,7 @@ code with tildes
73111
~~~
74112
</code></pre>'
75113

76-
try 'paragraph with trailing fenced block' \
114+
try -ffencedcode 'paragraph with trailing fenced block' \
77115
'text text text
78116
text text text
79117
~~~
@@ -85,7 +123,69 @@ text text text
85123
code code code?
86124
~~~</p>'
87125

88-
fi
126+
try -ffencedcode 'fenced code blocks with backtick delimiters' \
127+
'```
128+
code
129+
```' \
130+
'<pre><code>code
131+
</code></pre>'
132+
133+
try -ffencedcode 'fenced code block with mismatched delimters' \
134+
'```
135+
code
136+
~~~' \
137+
'<p>```
138+
code
139+
~~~</p>'
140+
141+
try -ffencedcode 'fenced code block with lang attribute' \
142+
'```lang
143+
code
144+
```' \
145+
'<pre><code class="lang">code
146+
</code></pre>'
147+
148+
try -ffencedcode 'fenced code block with lang-name attribute' \
149+
'```lang-name
150+
code
151+
```' \
152+
'<pre><code class="lang-name">code
153+
</code></pre>'
154+
155+
try -ffencedcode 'fenced code block with lang_name attribute' \
156+
'```lang_name
157+
code
158+
```' \
159+
'<pre><code class="lang_name">code
160+
</code></pre>'
161+
162+
try -ffencedcode 'fenced code block with lang attribute and space' \
163+
'``` lang
164+
code
165+
```' \
166+
'<pre><code class="lang">code
167+
</code></pre>'
168+
169+
try -ffencedcode 'fenced code block with lang attribute and multiple spaces' \
170+
'``` lang
171+
code
172+
```' \
173+
'<pre><code class="lang">code
174+
</code></pre>'
175+
176+
try -ffencedcode 'fenced code block with lang-name attribute and space' \
177+
'``` lang-name
178+
code
179+
```' \
180+
'<pre><code class="lang-name">code
181+
</code></pre>'
182+
183+
try -ffencedcode 'fenced code block with lang_name attribute and space' \
184+
'``` lang_name
185+
code
186+
```' \
187+
'<pre><code class="lang_name">code
188+
</code></pre>'
89189

90190
summary $0
91191
exit $rc

discount/tests/defects.t

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
. tests/functions.sh
2+
3+
title "reported defects"
4+
5+
rc=0
6+
MARKDOWN_FLAGS=
7+
8+
try 'masses of non-block html' \
9+
'<span>foo</span><br>
10+
<br>
11+
<span>bar</span><br>' \
12+
'<p><span>foo</span><br>
13+
<br>
14+
<span>bar</span><br></p>'
15+
16+
try -fautolink -G 'autolink + github-flavoured markdown' \
17+
'http://foo
18+
bar' \
19+
'<p><a href="http://foo">http://foo</a><br/>
20+
bar</p>'
21+
22+
try 'unterminated <p> block' '<p></>*' '<p><p></>*</p>'
23+
24+
summary $0
25+
exit $rc

discount/tests/dl.t

+28-18
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
title "definition lists"
44

5-
eval `./markdown -V | tr ' ' '\n' | grep '^DL='`
6-
7-
DL=${DL:-BOTH}
8-
95
rc=0
106
MARKDOWN_FLAGS=
117

@@ -22,11 +18,11 @@ RSLT='<dl>
2218
<dd>eh?</dd>
2319
</dl>'
2420

25-
if [ "$DL" = "DISCOUNT" -o "$DL" = "BOTH" ]; then
26-
try -fdefinitionlist '=tag= generates definition lists' "$SRC" "$RSLT"
21+
# discount style
22+
try -fdefinitionlist '=tag= generates definition lists' "$SRC" "$RSLT"
2723

28-
try 'one item with two =tags=' \
29-
'=this=
24+
try 'one item with two =tags=' \
25+
'=this=
3026
=is=
3127
A test, eh?' \
3228
'<dl>
@@ -35,24 +31,22 @@ if [ "$DL" = "DISCOUNT" -o "$DL" = "BOTH" ]; then
3531
<dd>A test, eh?</dd>
3632
</dl>'
3733

38-
39-
try -fnodefinitionlist '=tag= does nothing' "$SRC" \
40-
'<p>=this=
34+
# extra style
35+
try -fnodefinitionlist,dlextra '=tag= does nothing' "$SRC" \
36+
'<p>=this=
4137
is an ugly
4238
=test=
4339
eh?</p>'
44-
fi
4540

46-
if [ "$DL" = "EXTRA" -o "$DL" = "BOTH" ]; then
47-
try 'markdown extra-style definition lists' \
41+
try -fdlextra 'markdown extra-style definition lists' \
4842
'foo
4943
: bar' \
5044
'<dl>
5145
<dt>foo</dt>
5246
<dd>bar</dd>
5347
</dl>'
5448

55-
try '... with two <dt>s in a row' \
49+
try -fdlextra '... with two <dt>s in a row' \
5650
'foo
5751
bar
5852
: baz' \
@@ -62,7 +56,7 @@ bar
6256
<dd>baz</dd>
6357
</dl>'
6458

65-
try '... with two <dd>s in a row' \
59+
try -fdlextra '... with two <dd>s in a row' \
6660
'foo
6761
: bar
6862
: baz' \
@@ -72,7 +66,7 @@ bar
7266
<dd>baz</dd>
7367
</dl>'
7468

75-
try '... with blanks between list items' \
69+
try -fdlextra '... with blanks between list items' \
7670
'foo
7771
: bar
7872
@@ -85,7 +79,23 @@ zip
8579
<dd>zap</dd>
8680
</dl>'
8781

88-
fi
82+
# Hmm, redundancy...
83+
SRC='foo
84+
: bar
85+
86+
=this=
87+
is ugly'
88+
RSLT='<p>foo
89+
: bar</p>
90+
91+
<p>=this=
92+
is ugly</p>'
93+
try -fnodldiscount '... with definitionlists enabled but all styles disabled' \
94+
"$SRC" \
95+
"$RSLT"
96+
try -fnodefinitionlist,dldiscount,dlextra '... with definitionlists disabled but all styles enabled' \
97+
"$SRC" \
98+
"$RSLT"
8999

90100
summary $0
91101
exit $rc

0 commit comments

Comments
 (0)