@@ -151,6 +151,13 @@ void main() {
151
151
// Block content.
152
152
//
153
153
154
+ testParse ('parse <br> in block context' ,
155
+ '<br><p>a</p><br>' , const [ // TODO not sure how to reproduce this example
156
+ LineBreakNode (),
157
+ ParagraphNode (nodes: [TextNode ('a' )]),
158
+ LineBreakNode (),
159
+ ]);
160
+
154
161
testParse ('parse two plain-text paragraphs' ,
155
162
// "hello\n\nworld"
156
163
'<p>hello</p>\n <p>world</p>' , const [
@@ -237,5 +244,50 @@ void main() {
237
244
]);
238
245
});
239
246
240
- // TODO write more tests for this code
247
+ testParse ('parse quotations' ,
248
+ // "```quote\nwords\n```"
249
+ '<blockquote>\n <p>words</p>\n </blockquote>' , const [
250
+ QuotationNode ([ParagraphNode (nodes: [TextNode ('words' )])]),
251
+ ]);
252
+
253
+ testParse ('parse code blocks, no language' ,
254
+ // "```\nverb\natim\n```"
255
+ '<div class="codehilite"><pre><span></span><code>verb\n atim\n </code></pre></div>' , const [
256
+ CodeBlockNode (text: 'verb\n atim' ),
257
+ ]);
258
+
259
+ testParse ('parse code blocks, with highlighted language' ,
260
+ // "```dart\nclass A {}\n```"
261
+ '<div class="codehilite" data-code-language="Dart"><pre>'
262
+ '<span></span><code><span class="kd">class</span><span class="w"> </span>'
263
+ '<span class="nc">A</span><span class="w"> </span><span class="p">{}</span>'
264
+ '\n </code></pre></div>' , const [
265
+ CodeBlockNode (text: 'class A {}' ),
266
+ ]);
267
+
268
+ testParse ('parse image' ,
269
+ // "https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3"
270
+ '<div class="message_inline_image">'
271
+ '<a href="https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3">'
272
+ '<img src="https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3">'
273
+ '</a></div>' , const [
274
+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3' ),
275
+ ]);
276
+
277
+ testParse ('parse nested lists, quotes, headings, code blocks' ,
278
+ // "1. > ###### two\n > * three\n\n four"
279
+ '<ol>\n <li>\n <blockquote>\n <h6>two</h6>\n <ul>\n <li>three</li>\n '
280
+ '</ul>\n </blockquote>\n <div class="codehilite"><pre><span></span>'
281
+ '<code>four\n </code></pre></div>\n\n </li>\n </ol>' , const [
282
+ ListNode (ListStyle .ordered, [[
283
+ QuotationNode ([
284
+ HeadingNode (level: HeadingLevel .h6, nodes: [TextNode ('two' )]),
285
+ ListNode (ListStyle .unordered, [[
286
+ ParagraphNode (wasImplicit: true , nodes: [TextNode ('three' )]),
287
+ ]]),
288
+ ]),
289
+ CodeBlockNode (text: 'four' ),
290
+ ParagraphNode (wasImplicit: true , nodes: [TextNode ('\n\n ' )]), // TODO avoid this; it renders wrong
291
+ ]]),
292
+ ]);
241
293
}
0 commit comments