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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
extern crate micromark;
use micromark::{micromark, micromark_with_options, Constructs, Options};
use pretty_assertions::assert_eq;
#[test]
fn block_quote() {
assert_eq!(
micromark("> # a\n> b\n> c"),
"<blockquote>\n<h1>a</h1>\n<p>b\nc</p>\n</blockquote>",
"should support block quotes"
);
assert_eq!(
micromark("># a\n>b\n> c"),
"<blockquote>\n<h1>a</h1>\n<p>b\nc</p>\n</blockquote>",
"should support block quotes w/o space"
);
assert_eq!(
micromark(" > # a\n > b\n > c"),
"<blockquote>\n<h1>a</h1>\n<p>b\nc</p>\n</blockquote>",
"should support prefixing block quotes w/ spaces"
);
assert_eq!(
micromark(" > # a\n > b\n > c"),
"<pre><code>> # a\n> b\n> c\n</code></pre>",
"should not support block quotes w/ 4 spaces"
);
assert_eq!(
micromark("> # a\n> b\nc"),
"<blockquote>\n<h1>a</h1>\n<p>b\nc</p>\n</blockquote>",
"should support lazy content lines"
);
assert_eq!(
micromark("> a\nb\n> c"),
"<blockquote>\n<p>a\nb\nc</p>\n</blockquote>",
"should support lazy content lines inside block quotes"
);
assert_eq!(
micromark("> a\n> ---"),
"<blockquote>\n<h2>a</h2>\n</blockquote>",
"should support setext headings underlines in block quotes"
);
assert_eq!(
micromark("> a\n---"),
"<blockquote>\n<p>a</p>\n</blockquote>\n<hr />",
"should not support lazy setext headings underlines in block quotes"
);
assert_eq!(
micromark("> - a\n> - b"),
"<blockquote>\n<ul>\n<li>a</li>\n<li>b</li>\n</ul>\n</blockquote>",
"should support lists in block quotes"
);
assert_eq!(
micromark("> - a\n- b"),
"<blockquote>\n<ul>\n<li>a</li>\n</ul>\n</blockquote>\n<ul>\n<li>b</li>\n</ul>",
"should not support lazy lists in block quotes"
);
assert_eq!(
micromark("> a\n b"),
"<blockquote>\n<pre><code>a\n</code></pre>\n</blockquote>\n<pre><code>b\n</code></pre>",
"should not support lazy indented code in block quotes"
);
assert_eq!(
micromark("> ```\na\n```"),
"<blockquote>\n<pre><code></code></pre>\n</blockquote>\n<p>a</p>\n<pre><code></code></pre>\n",
"should not support lazy fenced code in block quotes (1)"
);
assert_eq!(
micromark("> a\n```\nb"),
"<blockquote>\n<p>a</p>\n</blockquote>\n<pre><code>b\n</code></pre>\n",
"should not support lazy fenced code in block quotes (2)"
);
assert_eq!(
micromark("> a\n - b"),
"<blockquote>\n<p>a\n- b</p>\n</blockquote>",
"should not support lazy indented code (or lazy list) in block quotes"
);
assert_eq!(
micromark("> [\na"),
"<blockquote>\n<p>[\na</p>\n</blockquote>",
"should support lazy, definition-like lines"
);
assert_eq!(
micromark("> [a]: b\nc"),
"<blockquote>\n<p>c</p>\n</blockquote>",
"should support a definition, followed by a lazy paragraph"
);
assert_eq!(
micromark(">"),
"<blockquote>\n</blockquote>",
"should support empty block quotes (1)"
);
assert_eq!(
micromark(">\n> \n> "),
"<blockquote>\n</blockquote>",
"should support empty block quotes (2)"
);
assert_eq!(
micromark(">\n> a\n> "),
"<blockquote>\n<p>a</p>\n</blockquote>",
"should support initial or final lazy empty block quote lines"
);
assert_eq!(
micromark("> a\n\n> b"),
"<blockquote>\n<p>a</p>\n</blockquote>\n<blockquote>\n<p>b</p>\n</blockquote>",
"should support adjacent block quotes"
);
assert_eq!(
micromark("> a\n> b"),
"<blockquote>\n<p>a\nb</p>\n</blockquote>",
"should support a paragraph in a block quote"
);
assert_eq!(
micromark("> a\n>\n> b"),
"<blockquote>\n<p>a</p>\n<p>b</p>\n</blockquote>",
"should support adjacent paragraphs in block quotes"
);
assert_eq!(
micromark("[a]\n\n> [a]: b"),
"<p><a href=\"b\">a</a></p>\n<blockquote>\n</blockquote>",
"should support a definition in a block quote (1)"
);
assert_eq!(
micromark("> [a]: b\n\n[a]"),
"<blockquote>\n</blockquote>\n<p><a href=\"b\">a</a></p>",
"should support a definition in a block quote (2)"
);
assert_eq!(
micromark("a\n> b"),
"<p>a</p>\n<blockquote>\n<p>b</p>\n</blockquote>",
"should support interrupting paragraphs w/ block quotes"
);
assert_eq!(
micromark("> a\n***\n> b"),
"<blockquote>\n<p>a</p>\n</blockquote>\n<hr />\n<blockquote>\n<p>b</p>\n</blockquote>",
"should support interrupting block quotes w/ thematic breaks"
);
assert_eq!(
micromark("> a\nb"),
"<blockquote>\n<p>a\nb</p>\n</blockquote>",
"should not support interrupting block quotes w/ paragraphs"
);
assert_eq!(
micromark("> a\n\nb"),
"<blockquote>\n<p>a</p>\n</blockquote>\n<p>b</p>",
"should support interrupting block quotes w/ blank lines"
);
assert_eq!(
micromark("> a\n>\nb"),
"<blockquote>\n<p>a</p>\n</blockquote>\n<p>b</p>",
"should not support interrupting a blank line in a block quotes w/ paragraphs"
);
assert_eq!(
micromark("> > > a\nb"),
"<blockquote>\n<blockquote>\n<blockquote>\n<p>a\nb</p>\n</blockquote>\n</blockquote>\n</blockquote>",
"should not support interrupting many block quotes w/ paragraphs (1)"
);
assert_eq!(
micromark(">>> a\n> b\n>>c"),
"<blockquote>\n<blockquote>\n<blockquote>\n<p>a\nb\nc</p>\n</blockquote>\n</blockquote>\n</blockquote>",
"should not support interrupting many block quotes w/ paragraphs (2)"
);
assert_eq!(
micromark("> a\n\n> b"),
"<blockquote>\n<pre><code>a\n</code></pre>\n</blockquote>\n<blockquote>\n<p>b</p>\n</blockquote>",
"should support 5 spaces for indented code, not 4"
);
assert_eq!(
micromark_with_options(
"> # a\n> b\n> c",
&Options {
constructs: Constructs {
block_quote: false,
..Constructs::default()
},
..Options::default()
}
),
"<p>> # a\n> b\n> c</p>",
"should support turning off block quotes"
);
}
|