Debian Codegraph @

src/tests/multiline_block_quotes.rs

raw
1 use super::*;
2
3 #[test]
4 fn multiline_block_quotes() {
5 html_opts!(
6 [extension.multiline_block_quotes],
7 concat!(">>>\n", "Paragraph 1\n", "\n", "Paragraph 2\n", ">>>\n",),
8 concat!(
9 "<blockquote>\n",
10 "<p>Paragraph 1</p>\n",
11 "<p>Paragraph 2</p>\n",
12 "</blockquote>\n",
13 ),
14 );
15
16 html_opts!(
17 [extension.multiline_block_quotes],
18 concat!(
19 "- item one\n",
20 "\n",
21 " >>>\n",
22 " Paragraph 1\n",
23 "\n",
24 " Paragraph 2\n",
25 " >>>\n",
26 "- item two\n"
27 ),
28 concat!(
29 "<ul>\n",
30 "<li>\n",
31 "<p>item one</p>\n",
32 "<blockquote>\n",
33 "<p>Paragraph 1</p>\n",
34 "<p>Paragraph 2</p>\n",
35 "</blockquote>\n",
36 "</li>\n",
37 "<li>\n",
38 "<p>item two</p>\n",
39 "</li>\n",
40 "</ul>\n",
41 ),
42 );
43 }
44
45 #[test]
46 fn sourcepos() {
47 assert_ast_match!(
48 [extension.multiline_block_quotes],
49 "- item one\n"
50 "\n"
51 " >>>\n"
52 " Paragraph 1\n"
53 " >>>\n"
54 "- item two\n",
55 (document (1:1-6:10) [
56 (list (1:1-6:10) [
57 (item (1:1-5:5) [
58 (paragraph (1:3-1:10) [
59 (text (1:3-1:10) "item one")
60 ])
61 (multiline_block_quote (3:3-5:5) [
62 (paragraph (4:3-4:13) [
63 (text (4:3-4:13) "Paragraph 1")
64 ])
65 ])
66 ])
67 (item (6:1-6:10) [
68 (paragraph (6:3-6:10) [
69 (text (6:3-6:10) "item two")
70 ])
71 ])
72 ])
73 ])
74 );
75 }
76
77 #[test]
78 fn sourcepos_with_block_quote() {
79 assert_ast_match!(
80 [extension.multiline_block_quotes],
81 ">>>\n"
82 "> a\n"
83 ">>>\n",
84 (document (1:1-3:3) [
85 (multiline_block_quote (1:1-3:3) [
86 (block_quote (2:1-2:3) [
87 (paragraph (2:3-2:3) [
88 (text (2:3-2:3) "a")
89 ])
90 ])
91 ])
92 ])
93 );
94 }
95
96 #[test]
97 fn sourcepos_with_block_quote_and_para() {
98 assert_ast_match!(
99 [extension.multiline_block_quotes],
100 ">>>\n"
101 "> a\n"
102 "\n"
103 "b\n"
104 ">>>\n",
105 (document (1:1-5:3) [
106 (multiline_block_quote (1:1-5:3) [
107 (block_quote (2:1-2:3) [
108 (paragraph (2:3-2:3) [
109 (text (2:3-2:3) "a")
110 ])
111 ])
112 (paragraph (4:1-4:1) [
113 (text (4:1-4:1) "b")
114 ])
115 ])
116 ])
117 );
118 }
119
120 #[test]
121 fn sourcepos_with_list() {
122 assert_ast_match!(
123 [extension.multiline_block_quotes],
124 ">>>\n"
125 "* a\n"
126 ">>>\n",
127 (document (1:1-3:3) [
128 (multiline_block_quote (1:1-3:3) [
129 (list (2:1-2:3) [
130 (item (2:1-2:3) [
131 (paragraph (2:3-2:3) [
132 (text (2:3-2:3) "a")
133 ])
134 ])
135 ])
136 ])
137 ])
138 );
139 }
140
141 #[test]
142 fn sourcepos_with_list_and_para() {
143 assert_ast_match!(
144 [extension.multiline_block_quotes],
145 ">>>\n"
146 "* a\n"
147 "\n"
148 "b\n"
149 ">>>\n",
150 (document (1:1-5:3) [
151 (multiline_block_quote (1:1-5:3) [
152 (list (2:1-2:3) [
153 (item (2:1-2:3) [
154 (paragraph (2:3-2:3) [
155 (text (2:3-2:3) "a")
156 ])
157 ])
158 ])
159 (paragraph (4:1-4:1) [
160 (text (4:1-4:1) "b")
161 ])
162 ])
163 ])
164 );
165 }
166
167 #[test]
168 fn sourcepos_with_block_quote_with_list() {
169 assert_ast_match!(
170 [extension.multiline_block_quotes],
171 ">>>\n"
172 "> * a\n"
173 ">>>\n",
174 (document (1:1-3:3) [
175 (multiline_block_quote (1:1-3:3) [
176 (block_quote (2:1-2:5) [
177 (list (2:3-2:5) [
178 (item (2:3-2:5) [
179 (paragraph (2:5-2:5) [
180 (text (2:5-2:5) "a")
181 ])
182 ])
183 ])
184 ])
185 ])
186 ])
187 );
188 }
189
190 #[test]
191 fn sourcepos_with_block_quote_with_list_and_para() {
192 assert_ast_match!(
193 [extension.multiline_block_quotes],
194 ">>>\n"
195 "> * a\n"
196 "\n"
197 "b\n"
198 ">>>\n",
199 (document (1:1-5:3) [
200 (multiline_block_quote (1:1-5:3) [
201 (block_quote (2:1-2:5) [
202 (list (2:3-2:5) [
203 (item (2:3-2:5) [
204 (paragraph (2:5-2:5) [
205 (text (2:5-2:5) "a")
206 ])
207 ])
208 ])
209 ])
210 (paragraph (4:1-4:1) [
211 (text (4:1-4:1) "b")
212 ])
213 ])
214 ])
215 );
216 }
217
218 #[test]
219 fn sourcepos_with_block_quote_with_block_quote_and_list() {
220 assert_ast_match!(
221 [extension.multiline_block_quotes],
222 ">>>\n"
223 ">> a\n"
224 ">> * b\n"
225 ">>>\n",
226 (document (1:1-4:3) [
227 (multiline_block_quote (1:1-4:3) [
228 (block_quote (2:1-3:6) [
229 (block_quote (2:2-3:6) [
230 (paragraph (2:4-2:4) [
231 (text (2:4-2:4) "a")
232 ])
233 (list (3:4-3:6) [
234 (item (3:4-3:6) [
235 (paragraph (3:6-3:6) [
236 (text (3:6-3:6) "b")
237 ])
238 ])
239 ])
240 ])
241 ])
242 ])
243 ])
244 );
245 }
246
247 #[test]
248 fn html_block_in_blockquote_in_mbq() {
249 html_opts!(
250 [extension.multiline_block_quotes, render.r#unsafe],
251 concat!(">>>\n", "<div>test</div>\n", ">>>\n"),
252 concat!("<blockquote>\n", "<div>test</div>\n", "</blockquote>\n",),
253 );
254
255 html_opts!(
256 [extension.multiline_block_quotes, render.r#unsafe],
257 concat!(">>>\n", "> <div>test</div>\n", ">>>\n"),
258 concat!(
259 "<blockquote>\n",
260 "<blockquote>\n",
261 "<div>test</div>\n",
262 "</blockquote>\n",
263 "</blockquote>\n",
264 ),
265 );
266 }
267
268 #[test]
269 fn mbq_as_list_item_with_list_item() {
270 html_opts!(
271 [extension.multiline_block_quotes, render.r#unsafe],
272 concat!(" - >>>\n", " - foo\n", " >>>"),
273 concat!(
274 "<ul>\n",
275 "<li>\n",
276 "<blockquote>\n",
277 "<ul>\n",
278 "<li>foo</li>\n",
279 "</ul>\n",
280 "</blockquote>\n",
281 "</li>\n",
282 "</ul>\n",
283 ),
284 );
285 }