@hcengineering/text-markdown 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1044 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
+ var import__ = require("..");
5
+ var import_compare = require("../compare");
6
+ const refUrl = "ref://";
7
+ const imageUrl = "http://localhost";
8
+ const options = { refUrl, imageUrl };
9
+ expect.extend({
10
+ toEqualMarkdown(received, expected) {
11
+ const pass = (0, import_compare.isMarkdownsEquals)(received, expected);
12
+ return {
13
+ message: /* @__PURE__ */ __name(() => pass ? `Expected markdown strings NOT to be equal:
14
+ Received:
15
+ ${received}
16
+ Expected:
17
+ ${expected}` : `Expected markdown strings to be equal:
18
+ Received:
19
+ ${received}
20
+ Expected:
21
+ ${expected}`, "message"),
22
+ pass
23
+ };
24
+ }
25
+ });
26
+ describe("markdownToMarkup", () => {
27
+ const tests = [
28
+ {
29
+ name: "simple text",
30
+ markdown: "Lorem ipsum dolor sit amet.",
31
+ markup: {
32
+ type: "doc",
33
+ content: [
34
+ {
35
+ type: "paragraph",
36
+ content: [
37
+ {
38
+ type: "text",
39
+ text: "Lorem ipsum dolor sit amet.",
40
+ marks: []
41
+ }
42
+ ]
43
+ }
44
+ ]
45
+ }
46
+ },
47
+ {
48
+ name: "text with heading",
49
+ markdown: `# Lorem ipsum
50
+
51
+ Lorem ipsum dolor sit amet.
52
+ `,
53
+ markup: {
54
+ type: "doc",
55
+ content: [
56
+ {
57
+ type: "heading",
58
+ attrs: { level: 1, marker: "#" },
59
+ content: [
60
+ {
61
+ type: "text",
62
+ text: "Lorem ipsum",
63
+ marks: []
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ type: "paragraph",
69
+ content: [
70
+ {
71
+ type: "text",
72
+ text: "Lorem ipsum dolor sit amet.",
73
+ marks: []
74
+ }
75
+ ]
76
+ }
77
+ ]
78
+ }
79
+ },
80
+ {
81
+ name: "bullet list",
82
+ markdown: `# bullet list
83
+ - list item 1
84
+ - list item 2
85
+ `,
86
+ markup: {
87
+ type: "doc",
88
+ content: [
89
+ {
90
+ type: "heading",
91
+ attrs: { level: 1, marker: "#" },
92
+ content: [
93
+ {
94
+ type: "text",
95
+ text: "bullet list",
96
+ marks: []
97
+ }
98
+ ]
99
+ },
100
+ {
101
+ type: "bulletList",
102
+ attrs: {
103
+ bullet: "-"
104
+ },
105
+ content: [
106
+ {
107
+ type: "listItem",
108
+ content: [
109
+ {
110
+ type: "paragraph",
111
+ content: [
112
+ {
113
+ type: "text",
114
+ text: "list item 1",
115
+ marks: []
116
+ }
117
+ ]
118
+ }
119
+ ]
120
+ },
121
+ {
122
+ type: "listItem",
123
+ content: [
124
+ {
125
+ type: "paragraph",
126
+ content: [
127
+ {
128
+ type: "text",
129
+ text: "list item 2",
130
+ marks: []
131
+ }
132
+ ]
133
+ }
134
+ ]
135
+ }
136
+ ]
137
+ }
138
+ ]
139
+ }
140
+ },
141
+ {
142
+ name: "todos",
143
+ markdown: `# TODO
144
+ - [ ] todo 1
145
+ - [x] todo 2
146
+ `,
147
+ markup: {
148
+ type: "doc",
149
+ content: [
150
+ {
151
+ type: "heading",
152
+ attrs: { level: 1, marker: "#" },
153
+ content: [
154
+ {
155
+ type: "text",
156
+ text: "TODO",
157
+ marks: []
158
+ }
159
+ ]
160
+ },
161
+ {
162
+ type: "todoList",
163
+ attrs: {
164
+ bullet: "-"
165
+ },
166
+ content: [
167
+ {
168
+ type: "todoItem",
169
+ attrs: { checked: false },
170
+ content: [
171
+ {
172
+ type: "paragraph",
173
+ content: [
174
+ {
175
+ type: "text",
176
+ text: "todo 1",
177
+ marks: []
178
+ }
179
+ ]
180
+ }
181
+ ]
182
+ },
183
+ {
184
+ type: "todoItem",
185
+ attrs: { checked: true },
186
+ content: [
187
+ {
188
+ type: "paragraph",
189
+ content: [
190
+ {
191
+ type: "text",
192
+ text: "todo 2",
193
+ marks: []
194
+ }
195
+ ]
196
+ }
197
+ ]
198
+ }
199
+ ]
200
+ }
201
+ ]
202
+ }
203
+ },
204
+ {
205
+ name: "todos followed by list items",
206
+ markdown: `# todo and list
207
+ - [ ] todo 1
208
+ - [x] todo 2
209
+ - list item 1
210
+ - list item 2
211
+ `,
212
+ markup: {
213
+ type: "doc",
214
+ content: [
215
+ {
216
+ type: "heading",
217
+ attrs: { level: 1, marker: "#" },
218
+ content: [
219
+ {
220
+ type: "text",
221
+ text: "todo and list",
222
+ marks: []
223
+ }
224
+ ]
225
+ },
226
+ {
227
+ type: "todoList",
228
+ attrs: {
229
+ bullet: "-"
230
+ },
231
+ content: [
232
+ {
233
+ type: "todoItem",
234
+ attrs: { checked: false },
235
+ content: [
236
+ {
237
+ type: "paragraph",
238
+ content: [
239
+ {
240
+ type: "text",
241
+ text: "todo 1",
242
+ marks: []
243
+ }
244
+ ]
245
+ }
246
+ ]
247
+ },
248
+ {
249
+ type: "todoItem",
250
+ attrs: { checked: true },
251
+ content: [
252
+ {
253
+ type: "paragraph",
254
+ content: [
255
+ {
256
+ type: "text",
257
+ text: "todo 2",
258
+ marks: []
259
+ }
260
+ ]
261
+ }
262
+ ]
263
+ }
264
+ ]
265
+ },
266
+ {
267
+ type: "bulletList",
268
+ attrs: {
269
+ bullet: "-"
270
+ },
271
+ content: [
272
+ {
273
+ type: "listItem",
274
+ content: [
275
+ {
276
+ type: "paragraph",
277
+ content: [
278
+ {
279
+ type: "text",
280
+ text: "list item 1",
281
+ marks: []
282
+ }
283
+ ]
284
+ }
285
+ ]
286
+ },
287
+ {
288
+ type: "listItem",
289
+ content: [
290
+ {
291
+ type: "paragraph",
292
+ content: [
293
+ {
294
+ type: "text",
295
+ text: "list item 2",
296
+ marks: []
297
+ }
298
+ ]
299
+ }
300
+ ]
301
+ }
302
+ ]
303
+ }
304
+ ]
305
+ }
306
+ },
307
+ {
308
+ name: "todos followed by list items",
309
+ markdown: `# mixed lists
310
+ - [ ] todo 1
311
+ - list item 1
312
+ - [x] todo 2
313
+ - list item 2
314
+ `,
315
+ markup: {
316
+ type: "doc",
317
+ content: [
318
+ {
319
+ type: "heading",
320
+ attrs: { level: 1, marker: "#" },
321
+ content: [
322
+ {
323
+ type: "text",
324
+ text: "mixed lists",
325
+ marks: []
326
+ }
327
+ ]
328
+ },
329
+ {
330
+ type: "todoList",
331
+ attrs: {
332
+ bullet: "-"
333
+ },
334
+ content: [
335
+ {
336
+ type: "todoItem",
337
+ attrs: { checked: false },
338
+ content: [
339
+ {
340
+ type: "paragraph",
341
+ content: [
342
+ {
343
+ type: "text",
344
+ text: "todo 1",
345
+ marks: []
346
+ }
347
+ ]
348
+ }
349
+ ]
350
+ }
351
+ ]
352
+ },
353
+ {
354
+ type: "bulletList",
355
+ attrs: {
356
+ bullet: "-"
357
+ },
358
+ content: [
359
+ {
360
+ type: "listItem",
361
+ content: [
362
+ {
363
+ type: "paragraph",
364
+ content: [
365
+ {
366
+ type: "text",
367
+ text: "list item 1",
368
+ marks: []
369
+ }
370
+ ]
371
+ }
372
+ ]
373
+ }
374
+ ]
375
+ },
376
+ {
377
+ type: "todoList",
378
+ attrs: {
379
+ bullet: "-"
380
+ },
381
+ content: [
382
+ {
383
+ type: "todoItem",
384
+ attrs: { checked: true },
385
+ content: [
386
+ {
387
+ type: "paragraph",
388
+ content: [
389
+ {
390
+ type: "text",
391
+ text: "todo 2",
392
+ marks: []
393
+ }
394
+ ]
395
+ }
396
+ ]
397
+ }
398
+ ]
399
+ },
400
+ {
401
+ type: "bulletList",
402
+ attrs: {
403
+ bullet: "-"
404
+ },
405
+ content: [
406
+ {
407
+ type: "listItem",
408
+ content: [
409
+ {
410
+ type: "paragraph",
411
+ content: [
412
+ {
413
+ type: "text",
414
+ text: "list item 2",
415
+ marks: []
416
+ }
417
+ ]
418
+ }
419
+ ]
420
+ }
421
+ ]
422
+ }
423
+ ]
424
+ }
425
+ },
426
+ {
427
+ name: "nested todos",
428
+ markdown: `# nested todos
429
+ - [ ] todo
430
+ - [x] sub todo
431
+ `,
432
+ markup: {
433
+ type: "doc",
434
+ content: [
435
+ {
436
+ type: "heading",
437
+ attrs: { level: 1, marker: "#" },
438
+ content: [
439
+ {
440
+ type: "text",
441
+ text: "nested todos",
442
+ marks: []
443
+ }
444
+ ]
445
+ },
446
+ {
447
+ type: "todoList",
448
+ attrs: {
449
+ bullet: "-"
450
+ },
451
+ content: [
452
+ {
453
+ type: "todoItem",
454
+ attrs: { checked: false },
455
+ content: [
456
+ {
457
+ type: "paragraph",
458
+ content: [
459
+ {
460
+ type: "text",
461
+ text: "todo",
462
+ marks: []
463
+ }
464
+ ]
465
+ },
466
+ {
467
+ type: "todoList",
468
+ attrs: {
469
+ bullet: "-"
470
+ },
471
+ content: [
472
+ {
473
+ type: "todoItem",
474
+ attrs: { checked: true },
475
+ content: [
476
+ {
477
+ type: "paragraph",
478
+ content: [
479
+ {
480
+ type: "text",
481
+ text: "sub todo",
482
+ marks: []
483
+ }
484
+ ]
485
+ }
486
+ ]
487
+ }
488
+ ]
489
+ }
490
+ ]
491
+ }
492
+ ]
493
+ }
494
+ ]
495
+ }
496
+ },
497
+ {
498
+ name: "nested lists",
499
+ markdown: `# nested lists
500
+ - [ ] todo
501
+ - sub list item
502
+ - [x] sub todo
503
+ - list item
504
+ - [x] sub todo
505
+ - sub list item
506
+ `,
507
+ markup: {
508
+ type: "doc",
509
+ content: [
510
+ {
511
+ type: "heading",
512
+ attrs: { level: 1, marker: "#" },
513
+ content: [
514
+ {
515
+ type: "text",
516
+ text: "nested lists",
517
+ marks: []
518
+ }
519
+ ]
520
+ },
521
+ {
522
+ type: "todoList",
523
+ attrs: {
524
+ bullet: "-"
525
+ },
526
+ content: [
527
+ {
528
+ type: "todoItem",
529
+ attrs: { checked: false },
530
+ content: [
531
+ {
532
+ type: "paragraph",
533
+ content: [
534
+ {
535
+ type: "text",
536
+ text: "todo",
537
+ marks: []
538
+ }
539
+ ]
540
+ },
541
+ {
542
+ type: "bulletList",
543
+ attrs: {
544
+ bullet: "-"
545
+ },
546
+ content: [
547
+ {
548
+ type: "listItem",
549
+ content: [
550
+ {
551
+ type: "paragraph",
552
+ content: [
553
+ {
554
+ type: "text",
555
+ text: "sub list item",
556
+ marks: []
557
+ }
558
+ ]
559
+ }
560
+ ]
561
+ }
562
+ ]
563
+ },
564
+ {
565
+ type: "todoList",
566
+ attrs: {
567
+ bullet: "-"
568
+ },
569
+ content: [
570
+ {
571
+ type: "todoItem",
572
+ attrs: { checked: true },
573
+ content: [
574
+ {
575
+ type: "paragraph",
576
+ content: [
577
+ {
578
+ type: "text",
579
+ text: "sub todo",
580
+ marks: []
581
+ }
582
+ ]
583
+ }
584
+ ]
585
+ }
586
+ ]
587
+ }
588
+ ]
589
+ }
590
+ ]
591
+ },
592
+ {
593
+ type: "bulletList",
594
+ attrs: {
595
+ bullet: "-"
596
+ },
597
+ content: [
598
+ {
599
+ type: "listItem",
600
+ content: [
601
+ {
602
+ type: "paragraph",
603
+ content: [
604
+ {
605
+ type: "text",
606
+ text: "list item",
607
+ marks: []
608
+ }
609
+ ]
610
+ },
611
+ {
612
+ type: "todoList",
613
+ attrs: {
614
+ bullet: "-"
615
+ },
616
+ content: [
617
+ {
618
+ type: "todoItem",
619
+ attrs: { checked: true },
620
+ content: [
621
+ {
622
+ type: "paragraph",
623
+ content: [
624
+ {
625
+ type: "text",
626
+ text: "sub todo",
627
+ marks: []
628
+ }
629
+ ]
630
+ }
631
+ ]
632
+ }
633
+ ]
634
+ },
635
+ {
636
+ type: "bulletList",
637
+ attrs: {
638
+ bullet: "-"
639
+ },
640
+ content: [
641
+ {
642
+ type: "listItem",
643
+ content: [
644
+ {
645
+ type: "paragraph",
646
+ content: [
647
+ {
648
+ type: "text",
649
+ text: "sub list item",
650
+ marks: []
651
+ }
652
+ ]
653
+ }
654
+ ]
655
+ }
656
+ ]
657
+ }
658
+ ]
659
+ }
660
+ ]
661
+ }
662
+ ]
663
+ }
664
+ },
665
+ {
666
+ name: "nested todos",
667
+ markdown: `# nested todos
668
+ - [ ] todo
669
+ - [x] sub todo
670
+ `,
671
+ markup: {
672
+ type: "doc",
673
+ content: [
674
+ {
675
+ type: "heading",
676
+ attrs: { level: 1, marker: "#" },
677
+ content: [
678
+ {
679
+ type: "text",
680
+ text: "nested todos",
681
+ marks: []
682
+ }
683
+ ]
684
+ },
685
+ {
686
+ type: "todoList",
687
+ attrs: {
688
+ bullet: "-"
689
+ },
690
+ content: [
691
+ {
692
+ type: "todoItem",
693
+ attrs: { checked: false },
694
+ content: [
695
+ {
696
+ type: "paragraph",
697
+ content: [
698
+ {
699
+ type: "text",
700
+ text: "todo",
701
+ marks: []
702
+ }
703
+ ]
704
+ },
705
+ {
706
+ type: "todoList",
707
+ attrs: {
708
+ bullet: "-"
709
+ },
710
+ content: [
711
+ {
712
+ type: "todoItem",
713
+ attrs: { checked: true },
714
+ content: [
715
+ {
716
+ type: "paragraph",
717
+ content: [
718
+ {
719
+ type: "text",
720
+ text: "sub todo",
721
+ marks: []
722
+ }
723
+ ]
724
+ }
725
+ ]
726
+ }
727
+ ]
728
+ }
729
+ ]
730
+ }
731
+ ]
732
+ }
733
+ ]
734
+ }
735
+ },
736
+ {
737
+ name: "mermaid diagram",
738
+ markdown: "```mermaid\ngraph TD;\n A-->B;\n A-->C;\n B-->D;\n C-->D;\n```",
739
+ markup: {
740
+ type: "doc",
741
+ content: [
742
+ {
743
+ type: "mermaid",
744
+ attrs: {
745
+ language: "mermaid"
746
+ },
747
+ content: [
748
+ {
749
+ marks: [],
750
+ text: "graph TD;\n A-->B;\n A-->C;\n B-->D;\n C-->D;",
751
+ type: "text"
752
+ }
753
+ ]
754
+ }
755
+ ]
756
+ }
757
+ },
758
+ {
759
+ name: "embed",
760
+ markdown: '<a href="http://localhost/embed" data-type="embed">http:&#x2F;&#x2F;localhost&#x2F;embed</a>',
761
+ markup: {
762
+ type: "doc",
763
+ content: [
764
+ {
765
+ type: "paragraph",
766
+ content: [
767
+ {
768
+ type: "embed",
769
+ attrs: { src: "http://localhost/embed" },
770
+ content: []
771
+ }
772
+ ]
773
+ }
774
+ ]
775
+ }
776
+ },
777
+ {
778
+ name: "embed-uri-escape",
779
+ markdown: '<a href="http://localhost/embed%20spaces" data-type="embed">http:&#x2F;&#x2F;localhost&#x2F;embed spaces</a>',
780
+ markup: {
781
+ type: "doc",
782
+ content: [
783
+ {
784
+ type: "paragraph",
785
+ content: [
786
+ {
787
+ type: "embed",
788
+ attrs: { src: "http://localhost/embed spaces" },
789
+ content: []
790
+ }
791
+ ]
792
+ }
793
+ ]
794
+ }
795
+ },
796
+ {
797
+ name: "embed-html-escape",
798
+ markdown: '<a href="http://localhost/embed%3Chtml%3E" data-type="embed">http:&#x2F;&#x2F;localhost&#x2F;embed&lt;html&gt;</a>',
799
+ markup: {
800
+ type: "doc",
801
+ content: [
802
+ {
803
+ type: "paragraph",
804
+ content: [
805
+ {
806
+ type: "embed",
807
+ attrs: { src: "http://localhost/embed<html>" },
808
+ content: []
809
+ }
810
+ ]
811
+ }
812
+ ]
813
+ }
814
+ },
815
+ {
816
+ name: "multiline image alt",
817
+ markdown: "![line0\\\n\\\nline1](http://example.com/image.png)",
818
+ markup: {
819
+ type: "doc",
820
+ content: [
821
+ {
822
+ type: "paragraph",
823
+ content: [
824
+ {
825
+ type: "image",
826
+ attrs: { src: "http://example.com/image.png", alt: "line0\n\nline1" },
827
+ content: []
828
+ }
829
+ ]
830
+ }
831
+ ]
832
+ }
833
+ },
834
+ {
835
+ name: "image in a table cell",
836
+ markdown: '<table><tbody><tr><td><p>Some text</p><p> <img src="files/image_1.png" alt="image-alt"/></p></td></tr></tbody></table>',
837
+ markup: {
838
+ type: "doc",
839
+ content: [
840
+ {
841
+ type: "table",
842
+ content: [
843
+ {
844
+ type: "tableRow",
845
+ content: [
846
+ {
847
+ type: "tableCell",
848
+ attrs: {
849
+ colspan: void 0,
850
+ rowspan: void 0,
851
+ colwidth: void 0
852
+ },
853
+ content: [
854
+ {
855
+ type: "paragraph",
856
+ content: [
857
+ {
858
+ type: "text",
859
+ text: "Some text"
860
+ }
861
+ ]
862
+ },
863
+ {
864
+ type: "paragraph",
865
+ attrs: {
866
+ textAlign: null
867
+ },
868
+ content: [
869
+ {
870
+ type: "text",
871
+ text: " "
872
+ },
873
+ {
874
+ type: "image",
875
+ attrs: {
876
+ src: "files/image_1.png",
877
+ alt: "image-alt",
878
+ "file-id": null,
879
+ title: null
880
+ }
881
+ }
882
+ ]
883
+ }
884
+ ]
885
+ }
886
+ ]
887
+ }
888
+ ]
889
+ }
890
+ ]
891
+ }
892
+ }
893
+ ];
894
+ describe("to markup", () => {
895
+ tests.forEach(({ name, markdown, markup }) => {
896
+ it(name, () => {
897
+ const parsed = (0, import__.markdownToMarkup)(markdown, options);
898
+ expect(parsed).toEqual(markup);
899
+ });
900
+ });
901
+ });
902
+ describe("to markup and back", () => {
903
+ tests.forEach(({ name, markdown, markup }) => {
904
+ it(name, () => {
905
+ const json = (0, import__.markdownToMarkup)(markdown, options);
906
+ const serialized = (0, import__.markupToMarkdown)(json, options);
907
+ expect(serialized).toEqualMarkdown(markdown);
908
+ });
909
+ });
910
+ });
911
+ });
912
+ describe("markupToMarkdown", () => {
913
+ const tests = [
914
+ {
915
+ name: "links",
916
+ markdown: `[Link](https://example.com)
917
+
918
+ [Link with spaces](<https://example.com/with spaces>)
919
+
920
+ [Link with spaces and braces](<https://example.com/\\<with spaces\\>>)`,
921
+ markup: {
922
+ type: "doc",
923
+ content: [
924
+ {
925
+ type: "paragraph",
926
+ content: [
927
+ {
928
+ type: "text",
929
+ text: "Link",
930
+ marks: [{ type: "link", attrs: { href: "https://example.com" } }]
931
+ }
932
+ ]
933
+ },
934
+ {
935
+ type: "paragraph",
936
+ content: [
937
+ {
938
+ type: "text",
939
+ text: "Link with spaces",
940
+ marks: [{ type: "link", attrs: { href: "https://example.com/with spaces" } }]
941
+ }
942
+ ]
943
+ },
944
+ {
945
+ type: "paragraph",
946
+ content: [
947
+ {
948
+ type: "text",
949
+ text: "Link with spaces and braces",
950
+ marks: [{ type: "link", attrs: { href: "https://example.com/<with spaces>" } }]
951
+ }
952
+ ]
953
+ }
954
+ ]
955
+ }
956
+ }
957
+ ];
958
+ describe("to markdown", () => {
959
+ tests.forEach(({ name, markdown, markup }) => {
960
+ it(name, () => {
961
+ const result = (0, import__.markupToMarkdown)(markup, options);
962
+ expect(result).toEqual(markdown);
963
+ });
964
+ });
965
+ });
966
+ });
967
+ describe("markdownToMarkup -> markupToMarkdown", () => {
968
+ const tests = [
969
+ { name: "Italic", markdown: "*Asteriscs* and _Underscores_" },
970
+ { name: "Bold", markdown: "**Asteriscs** and __Underscores__" },
971
+ { name: "Bullet list with asteriscs", markdown: "Asterisks :\r\n* Firstly\r\n* Secondly" },
972
+ { name: "Bullet list with dashes", markdown: "Dashes :\r\n- Firstly\r\n- Secondly" },
973
+ { name: "TODO list with asteriscs", markdown: "* [ ] Take\n* [ ] Do\n\n" },
974
+ { name: "TODO list with dashes", markdown: "- [x] Take\n- [ ] Do\n\n" },
975
+ {
976
+ name: "Different markers",
977
+ markdown: "Asterisks bulleted list:\r\n* Asterisks: *Italic* and **Bold*** Underscores: _Italic_ and __Bold__\r\n\r\nDash bulleted list:\r\n- Asterisks: *Italic* and **Bold**\r\n- Underscores: _Italic_ and __Bold__\r\n-"
978
+ },
979
+ { name: "Single line comment", markdown: "<!-- Do not erase me -->" },
980
+ {
981
+ name: "Multsiline comment",
982
+ markdown: '"<!--\r\n\r\nPlease title your PR as follows: `module: description` (e.g. `time: fix date format`).\r\nAlways start with the thing you are fixing, then describe the fix.\r\nDon\'t use past tense (e.g. "fixed foo bar").\r\n\r\nExplain what your PR does and why.\r\n\r\nIf you are adding a new function, please document it and add tests:\r\n\r\n```\r\n// foo does foo and bar\r\nfn foo() {\r\n\r\n// file_test.v\r\nfn test_foo() {\r\n assert foo() == ...\r\n ...\r\n}\r\n```\r\n\r\nIf you are fixing a bug, please add a test that covers it.\r\n\r\nBefore submitting a PR, please run `v test-all` .\r\nSee also `TESTS.md`.\r\n\r\nI try to process PRs as soon as possible. They should be handled within 24 hours.\r\n\r\nApplying labels to PRs is not needed.\r\n\r\nThanks a lot for your contribution!\r\n\r\n-->\r\n\r\nThis PR fix issue #22424\r\n\r\n\r\n"'
983
+ },
984
+ {
985
+ name: "Link",
986
+ markdown: "See [link](https://example.com)"
987
+ },
988
+ {
989
+ name: "Link with spaces",
990
+ markdown: "See [link](<https://example.com/with spaces>)",
991
+ alternate: "See [link](https://example.com/with%20spaces)"
992
+ },
993
+ {
994
+ name: "Link with spaces and braces",
995
+ markdown: "See [link](<https://example.com/\\<with spaces\\>>)",
996
+ alternate: "See [link](https://example.com/%3Cwith%20spaces%3E)"
997
+ },
998
+ {
999
+ name: "Codeblock",
1000
+ markdown: "```typescript\nconst x: number = 42;\n```"
1001
+ },
1002
+ {
1003
+ name: "Image",
1004
+ markdown: '<img width="320" height="160" src="http://example.com/image" alt="image">'
1005
+ },
1006
+ {
1007
+ name: "Images",
1008
+ markdown: `
1009
+ <img width="250" height="330" src="https://github.com/user-attachments/assets/f348e016-3f7d-45b1-b8a0-9098e9961885" alt="Screenshot 2025-09-11 at 15 42 40" />
1010
+
1011
+ <img width="250" height="230" alt="Screenshot 2025-09-11 at 15 43 42" src="https://github.com/user-attachments/assets/4502eba1-1f55-44df-b691-c4d3d3d3d67d" >
1012
+
1013
+ <img src="https://github.com/user-attachments/assets/e21431a3-2062-4b0b-9c8f-d06c92ede741" alt="Screenshot 2025-09-11 at 15 43 50" width="250" height="210" >`
1014
+ },
1015
+ {
1016
+ name: "Image with multiline alt",
1017
+ markdown: "![link0\\\n\\\nline1](http://example.com/image.png)"
1018
+ },
1019
+ {
1020
+ name: "Table",
1021
+ markdown: "<table><tbody><tr><th><p>Header 1</p></th><th><p>Header 2</p></th></tr><tr><td><p>Cell 1</p></td><td><p>Cell 2</p></td></tr><tr><td><p>Cell 3</p></td><td><p>Cell 4</p></td></tr></tbody></table>"
1022
+ },
1023
+ {
1024
+ name: "Complex table",
1025
+ markdown: '<table><tbody><tr><td colspan="2" colwidth="320"><p>Header</p></td></tr><tr><td rowspan="2"><p>Cell 1</p></td><td><p>Cell 2</p></td></tr><tr><td><p>Cell 3</p></td></tr></tbody></table>'
1026
+ },
1027
+ {
1028
+ name: "Sub",
1029
+ markdown: '<sub>View in Huly <a href="http://localhost:8080/guest/github?token=token">TSK-50</a></sub>'
1030
+ }
1031
+ // {
1032
+ // name: 'Malformed',
1033
+ // markdown: '<foo>try to parse me</bar></buzz>'
1034
+ // }
1035
+ ];
1036
+ tests.forEach(({ name, markdown, alternate }) => {
1037
+ it(name, () => {
1038
+ const json = (0, import__.markdownToMarkup)(markdown, options);
1039
+ const serialized = (0, import__.markupToMarkdown)(json, options);
1040
+ expect(serialized).toEqualMarkdown(alternate ?? markdown);
1041
+ });
1042
+ });
1043
+ });
1044
+ //# sourceMappingURL=markdown.test.js.map