@@ -365,6 +365,71 @@ class ContentExample {
365
365
ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/51b70540cf6a5b3c8a0b919c893b8abddd447e88/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d33' ),
366
366
]),
367
367
]);
368
+
369
+ static const imageInImplicitParagraph = ContentExample (
370
+ 'image as immediate child in implicit paragraph' ,
371
+ "* https://chat.zulip.org/user_avatars/2/realm/icon.png" ,
372
+ '<ul>\n '
373
+ '<li>'
374
+ '<div class="message_inline_image">'
375
+ '<a href="https://chat.zulip.org/user_avatars/2/realm/icon.png">'
376
+ '<img src="https://chat.zulip.org/user_avatars/2/realm/icon.png"></a></div></li>\n </ul>' , [
377
+ ListNode (ListStyle .unordered, [[
378
+ ImageNodeList ([
379
+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ),
380
+ ]),
381
+ ]]),
382
+ ]);
383
+
384
+ static const imageClusterInImplicitParagraph = ContentExample (
385
+ 'image cluster in implicit paragraph' ,
386
+ "* [icon.png](https://chat.zulip.org/user_avatars/2/realm/icon.png) [icon.png](https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2)" ,
387
+ '<ul>\n '
388
+ '<li>'
389
+ '<a href="https://chat.zulip.org/user_avatars/2/realm/icon.png">icon.png</a> '
390
+ '<a href="https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2">icon.png</a>'
391
+ '<div class="message_inline_image">'
392
+ '<a href="https://chat.zulip.org/user_avatars/2/realm/icon.png" title="icon.png">'
393
+ '<img src="https://chat.zulip.org/user_avatars/2/realm/icon.png"></a></div>'
394
+ '<div class="message_inline_image">'
395
+ '<a href="https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2" title="icon.png">'
396
+ '<img src="https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2"></a></div></li>\n </ul>' , [
397
+ ListNode (ListStyle .unordered, [[
398
+ ParagraphNode (wasImplicit: true , links: null , nodes: [
399
+ LinkNode (url: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' , nodes: [TextNode ('icon.png' )]),
400
+ TextNode (' ' ),
401
+ LinkNode (url: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' , nodes: [TextNode ('icon.png' )]),
402
+ ]),
403
+ ImageNodeList ([
404
+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ),
405
+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' ),
406
+ ]),
407
+ ]]),
408
+ ]);
409
+
410
+ static final imageClusterInImplicitParagraphThenContent = ContentExample (
411
+ 'impossible content after image cluster in implicit paragraph' ,
412
+ // Image previews are always inserted at the end of the paragraph
413
+ // so it would be impossible to have content after.
414
+ null ,
415
+ '<ul>\n '
416
+ '<li>'
417
+ '<a href="https://chat.zulip.org/user_avatars/2/realm/icon.png">icon.png</a> '
418
+ '<div class="message_inline_image">'
419
+ '<a href="https://chat.zulip.org/user_avatars/2/realm/icon.png" title="icon.png">'
420
+ '<img src="https://chat.zulip.org/user_avatars/2/realm/icon.png"></a></div>'
421
+ 'more text</li>\n </ul>' , [
422
+ ListNode (ListStyle .unordered, [[
423
+ const ParagraphNode (wasImplicit: true , links: null , nodes: [
424
+ LinkNode (url: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' , nodes: [TextNode ('icon.png' )]),
425
+ TextNode (' ' ),
426
+ ]),
427
+ const ImageNodeList ([
428
+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ),
429
+ ]),
430
+ blockUnimplemented ('more text' ),
431
+ ]]),
432
+ ]);
368
433
}
369
434
370
435
UnimplementedBlockContentNode blockUnimplemented (String html) {
@@ -689,6 +754,9 @@ void main() {
689
754
testParseExample (ContentExample .imageCluster);
690
755
testParseExample (ContentExample .imageClusterThenContent);
691
756
testParseExample (ContentExample .imageMultipleClusters);
757
+ testParseExample (ContentExample .imageInImplicitParagraph);
758
+ testParseExample (ContentExample .imageClusterInImplicitParagraph);
759
+ testParseExample (ContentExample .imageClusterInImplicitParagraphThenContent);
692
760
693
761
testParse ('parse nested lists, quotes, headings, code blocks' ,
694
762
// "1. > ###### two\n > * three\n\n four"
0 commit comments