ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / base / test / browser / markdownRenderer.test.ts 1272 строк · изменён 14 нояб., 04:52
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
import assert from 'assert' ;
import { fillInIncompleteTokens, renderMarkdown, renderAsPlaintext } from '../../browser/markdownRenderer.js' ;
import { IMarkdownString, MarkdownString } from '../../common/htmlContent.js' ;
import * as marked from '../../common/marked/marked.js' ;
import { parse } from '../../common/marshalling.js' ;
import { isWeb } from '../../common/platform.js' ;
import { URI } from '../../common/uri.js' ;
import { ensureNoDisposablesAreLeakedInTestSuite
str HTMLElement
str body firstChild HTMLElement
actualNode HTMLElement expectedHtml
expectedNode expectedHtml
assert
actualNode expectedNode
store
markdown value
result HTMLElement store markdown element
assert result innerHTML
markdown value
result HTMLElement store markdown element
assert result
markdown value
result HTMLElement store markdown
sanitizerConfig
allowedLinkSchemes augment
element
anchor result
assert anchor
assert anchor dataset href
markdown value
result store markdown
href href href
element
anchor result
assert
anchorCount result length
text anchor textContent
href anchor dataset href
title anchor title
image result src
imageWidth result
imageHeight result
anchorCount
text
href
title
image
imageWidth
imageHeight
markdown value
result HTMLElement store markdown element
result
markdown value
result HTMLElement store markdown element
result
result HTMLElement store value element
result
result HTMLElement store value element
result
result HTMLElement store value element
result
isWeb
result HTMLElement store value element
result
simpleCodeBlockRenderer lang code HTMLElement
element document
element textContent code
element
markdown value
resolve
store markdown
asyncRenderCallback resolve
codeBlockRenderer simpleCodeBlockRenderer
markdown value
resolve reject
result markdown
asyncRenderCallback reject
codeBlockRenderer simpleCodeBlockRenderer
result
resolve
markdown value
resolve reject
x HTMLElement
result markdown
asyncRenderCallback reject
resolve
resolveCodeBlockRendering resolve
result
document
resolve
markdown value
lang resolve
store markdown
lang value
lang
lang value
assert lang
mds supportThemeIcons
mds
result HTMLElement store mds element
assert result innerHTML
mds supportThemeIcons
mds
result HTMLElement store mds element
assert result innerHTML
mds supportThemeIcons
mds
result HTMLElement store mds element
assert result innerHTML
mds supportThemeIcons
mds
result HTMLElement store mds element
assert result innerHTML
mds supportThemeIcons
mds
result HTMLElement store mds element
assert result innerHTML
mds supportThemeIcons supportHtml
mds
result HTMLElement store mds element
assert result innerHTML
mds supportThemeIcons
mds
result HTMLElement store mds element
assert result innerHTML
mds supportThemeIcons
mds
result HTMLElement store mds element
assert result innerHTML
markdown supportAlertSyntax
result store markdown element
blockquote result
assert blockquote
assert result innerHTML
assert result innerHTML
markdown
result store markdown element
blockquote result
assert blockquote
assert blockquote
assert result innerHTML
markdown supportAlertSyntax
result store markdown element
blockquote result
assert blockquote
md IMarkdownString
element store md element
anchor element
assert anchor
assert anchor dataset
uri anchor dataset
data script documentUri uri query
assert data
assert data script
assert data documentUri
md
supportHtml
result HTMLElement store md element
assert result innerHTML
md
isTrusted
supportHtml
result HTMLElement store md element
assert result innerHTML
md
isTrusted
supportHtml
result store md element
assert result innerHTML
md
isTrusted
supportHtml
md baseUri
result store md element
assert result innerHTML
md isTrusted
result store md element
assert
result a a a a
md
anchor store md element
assert
anchor anchor
md isTrusted
md baseUri
anchor store md element
assert
anchor anchor
fileUri
md
result store md element
anchor result
assert anchor
assert anchor title fileUri fsPath
fileUri
md
result store md element
anchor result
assert anchor
assert anchor title
fileUri
md
result store md element
anchor result
assert anchor
assert anchor title
markdown value
expected
result markdown
assert result expected
markdown value
expected
result markdown
assert result expected
markdown
value
expected
result markdown includeCodeBlocksFences
assert result expected
assert value
assert value
markdown value
assert
markdown
assert
markdown omitMarkdownSyntax
markdown value
assert markdown omitMarkdownSyntax
mds
mds
result store mds element
assert result innerHTML
mds supportHtml
mds
result store mds element
assert result innerHTML
mds supportHtml
mds
result store mds element
assert result innerHTML
mds supportHtml
mds
result store mds element
assert result innerHTML
isWeb
mds supportHtml
mds
result store mds element
assert result innerHTML
isWeb
mds supportHtml
mds
result store mds element
assert result innerHTML
mds
supportHtml
result store mds element
assert result innerHTML
tokenLists marked Token
tokenLists tokens
tokens t t raw
completeTable
tokens marked marked completeTable
newTokens tokens
assert newTokens tokens
incompleteTable
tokens marked marked incompleteTable
completeTableTokens marked marked completeTable
newTokens tokens
assert newTokens completeTableTokens
incompleteTable
tokens marked marked incompleteTable
completeTableTokens marked marked completeTable
newTokens tokens
newTokens
newTokens completeTableTokens
assert newTokens completeTableTokens
incompleteTable
tokens marked marked incompleteTable
completeTableTokens marked marked completeTable
newTokens tokens
newTokens
newTokens completeTableTokens
assert newTokens completeTableTokens
incompleteTable
tokens marked marked incompleteTable
completeTableTokens marked marked incompleteTable
newTokens tokens
newTokens
newTokens completeTableTokens
assert newTokens completeTableTokens
incompleteTable
tokens marked marked incompleteTable
completeTableTokens marked marked incompleteTable
newTokens tokens
assert newTokens completeTableTokens
incompleteTable
tokens marked marked incompleteTable
completeTableTokens marked marked incompleteTable
newTokens tokens
assert newTokens completeTableTokens
incompleteTable
tokens marked marked incompleteTable
completeTableTokens marked marked incompleteTable
newTokens tokens
assert newTokens completeTableTokens
incompleteTable
tokens marked marked incompleteTable
completeTableTokens marked marked completeTable
newTokens tokens
assert newTokens completeTableTokens
incompleteTable
tokens marked marked incompleteTable
completeTableTokens marked marked completeTable
newTokens tokens
assert newTokens completeTableTokens
incompleteTable
tokens marked marked incompleteTable
completeTableTokens marked marked completeTable
newTokens tokens
assert newTokens completeTableTokens
incompleteTable
tokens marked marked incompleteTable
newTokens tokens
assert newTokens tokens
incompleteTable
tokens marked marked incompleteTable
newTokens tokens
assert newTokens tokens
name delimiter
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete delimiter
assert newTokens completeTokens
text
tokens marked marked text
newTokens tokens
assert newTokens tokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete delimiter
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete delimiter
assert newTokens completeTokens
text
tokens marked marked text
newTokens tokens
assert newTokens tokens
text
tokens marked marked text
newTokens tokens
completeTokens marked marked text delimiter
assert newTokens completeTokens
text
tokens marked marked text
newTokens tokens
completeTokens marked marked text delimiter
assert newTokens completeTokens
text
tokens marked marked text
newTokens tokens
completeTokens marked marked text delimiter
assert newTokens completeTokens
text
tokens marked marked text
newTokens tokens
completeTokens marked marked text delimiter
assert newTokens completeTokens
text
tokens marked marked text
newTokens tokens
completeTokens marked marked text delimiter
assert newTokens completeTokens
list
tokens marked marked list
newTokens tokens
assert newTokens tokens
test
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
list
tokens marked marked list
newTokens tokens
assert newTokens tokens
list
tokens marked marked list
newTokens tokens
assert newTokens tokens
list
tokens marked marked list
newTokens tokens
assert newTokens tokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
text
tokens marked marked text
newTokens tokens
completeCodespanTokens marked marked text
assert newTokens completeCodespanTokens
text
tokens marked marked text
newTokens tokens
completeTokens marked marked text
assert newTokens completeTokens
text
tokens marked marked text
newTokens tokens
completeTokens marked marked
assert newTokens completeTokens
text
tokens marked marked text
newTokens tokens
completeTokens marked marked text
assert newTokens completeTokens
text
tokens marked marked text
newTokens tokens
completeTokens marked marked text
assert newTokens completeTokens
text
tokens marked marked text
newTokens tokens
completeTokens marked marked text
assert newTokens completeTokens
test
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
text
tokens marked marked text
newTokens tokens
assert newTokens tokens
text
tokens marked marked text
newTokens tokens
assert newTokens tokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
complete
tokens marked marked complete
newTokens tokens
completeTokens marked marked complete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
completeTokens marked marked incomplete
assert newTokens completeTokens
incomplete
tokens marked marked incomplete
newTokens tokens
assert newTokens tokens
incomplete
tokens marked marked incomplete
newTokens tokens
assert newTokens tokens
incomplete
tokens marked marked incomplete
newTokens tokens
assert newTokens tokens
incomplete
tokens marked marked incomplete
newTokens tokens
assert newTokens tokens
}
from
'../common/utils.js'
;
function
strToNode
(
:
string
)
:
{
return
new
DOMParser
(
)
.
parseFromString
(
,
'text/html'
)
.
.
as
;
}
function
assertNodeEquals
(
:
,
:
string
)
{
const
=
strToNode
(
)
;
.
ok
(
.
isEqualNode
(
)
,
` Expected: ${ expectedNode. outerHTML} \nActual: ${ actualNode. outerHTML} `
)
;
}
suite
(
'MarkdownRenderer'
,
(
)
=>
{
const
=
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
suite
(
'Sanitization'
,
(
)
=>
{
test
(
'Should not render images with unknown schemes'
,
(
)
=>
{
const
=
{
:
`  `
}
;
const
:
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
'<p><img alt="image"></p>'
)
;
}
)
;
test
(
'Strips links with disallowed schemes (default config)'
,
(
)
=>
{
const
=
{
:
` Read [](vscode-agent-host://my-host/path/to/foo.ts?_ah%3DeyJzY2hlbWUiOiJmaWxlIn0) `
}
;
const
:
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
querySelector
(
'a'
)
,
null
)
;
}
)
;
test
(
'Preserves link when scheme is allowed via allowedLinkSchemes.augment'
,
(
)
=>
{
const
=
{
:
` Read [](vscode-agent-host://my-host/path/to/foo.ts?_ah%3DeyJzY2hlbWUiOiJmaWxlIn0) `
}
;
const
:
=
.
add
(
renderMarkdown
(
,
{
:
{
:
{
:
[
'vscode-agent-host'
]
}
,
}
,
}
)
)
.
;
const
=
.
querySelector
(
'a'
)
;
.
ok
(
,
'expected <a> to be preserved when scheme is allowed'
)
;
.
strictEqual
(
!
.
.
,
'vscode-agent-host://my-host/path/to/foo.ts?_ah%3DeyJzY2hlbWUiOiJmaWxlIn0'
)
;
}
)
;
test
(
'Transforms parsed link targets without changing labels, titles, or code'
,
(
)
=>
{
const
=
{
:
'`[same](file:///same)` [a[b].ts](file:///same "file:///same") '
}
;
const
=
.
add
(
renderMarkdown
(
,
{
transformUri
:
=>
===
'file:///same'
?
'https://example.com/a.ts'
:
,
}
)
)
.
;
const
=
.
querySelector
(
'a'
)
;
.
deepStrictEqual
(
{
:
.
querySelectorAll
(
'a'
)
.
,
:
?.
,
:
?.
.
,
:
?.
,
:
.
querySelector
(
'img'
)
?.
,
:
.
querySelector
(
'img'
)
?.
getAttribute
(
'width'
)
,
:
.
querySelector
(
'img'
)
?.
getAttribute
(
'height'
)
,
}
,
{
:
1
,
:
'a[b].ts'
,
:
'https://example.com/a.ts'
,
:
'file:///same'
,
:
'https://example.com/a.ts'
,
:
'10'
,
:
'20'
,
}
,
)
;
}
)
;
}
)
;
suite
(
'Images'
,
(
)
=>
{
test
(
'image rendering conforms to default'
,
(
)
=>
{
const
=
{
:
`  `
}
;
const
:
=
.
add
(
renderMarkdown
(
)
)
.
;
assertNodeEquals
(
,
'<div><p><img title="caption" alt="image" src="http://example.com/cat.gif"></p></div>'
)
;
}
)
;
test
(
'image rendering conforms to default without title'
,
(
)
=>
{
const
=
{
:
`  `
}
;
const
:
=
.
add
(
renderMarkdown
(
)
)
.
;
assertNodeEquals
(
,
'<div><p><img alt="image" src="http://example.com/cat.gif"></p></div>'
)
;
}
)
;
test
(
'image width from title params'
,
(
)
=>
{
const
:
=
.
add
(
renderMarkdown
(
{
:
`  `
}
)
)
.
;
assertNodeEquals
(
,
` <div><p><img width="100" title="caption" alt="image" src="http://example.com/cat.gif"></p></div> `
)
;
}
)
;
test
(
'image height from title params'
,
(
)
=>
{
const
:
=
.
add
(
renderMarkdown
(
{
:
`  `
}
)
)
.
;
assertNodeEquals
(
,
` <div><p><img height="100" title="caption" alt="image" src="http://example.com/cat.gif"></p></div> `
)
;
}
)
;
test
(
'image width and height from title params'
,
(
)
=>
{
const
:
=
.
add
(
renderMarkdown
(
{
:
`  `
}
)
)
.
;
assertNodeEquals
(
,
` <div><p><img height="200" width="100" title="caption" alt="image" src="http://example.com/cat.gif"></p></div> `
)
;
}
)
;
test
(
'image with file uri should render as same origin uri'
,
(
)
=>
{
if
(
)
{
return
;
}
const
:
=
.
add
(
renderMarkdown
(
{
:
`  `
}
)
)
.
;
assertNodeEquals
(
,
'<div><p><img src="vscode-file://vscode-app/images/cat.gif" alt="image"></p></div>'
)
;
}
)
;
}
)
;
suite
(
'Code block renderer'
,
(
)
=>
{
const
=
(
:
string
,
:
string
)
:
Promise
<
>
=>
{
const
=
.
createElement
(
'code'
)
;
.
=
;
return
Promise
.
resolve
(
)
;
}
;
test
(
'asyncRenderCallback should be invoked for code blocks'
,
(
)
=>
{
const
=
{
:
'```js\n1 + 1;\n```'
}
;
return
new
Promise < void >
(
=>
{
.
add
(
renderMarkdown
(
,
{
:
,
:
}
)
)
;
}
)
;
}
)
;
test
(
'asyncRenderCallback should not be invoked if result is immediately disposed'
,
(
)
=>
{
const
=
{
:
'```js\n1 + 1;\n```'
}
;
return
new
Promise < void >
(
(
,
)
=>
{
const
=
renderMarkdown
(
,
{
:
,
:
}
)
;
.
dispose
(
)
;
setTimeout
(
,
10
)
;
}
)
;
}
)
;
test
(
'asyncRenderCallback should not be invoked if dispose is called before code block is rendered'
,
(
)
=>
{
const
=
{
:
'```js\n1 + 1;\n```'
}
;
return
new
Promise < void >
(
(
,
)
=>
{
let
resolveCodeBlockRendering
:
(
:
)
=>
void
;
const
=
renderMarkdown
(
,
{
:
,
codeBlockRenderer
:
(
)
=>
{
return
new
Promise
(
=>
{
=
;
}
)
;
}
}
)
;
setTimeout
(
(
)
=>
{
.
dispose
(
)
;
resolveCodeBlockRendering
(
.
createElement
(
'code'
)
)
;
setTimeout
(
,
10
)
;
}
,
10
)
;
}
)
;
}
)
;
test
(
'Code blocks should use leading language id (#157793)'
,
async
(
)
=>
{
const
=
{
:
'```js some other stuff\n1 + 1;\n```'
}
;
const
=
await
new
Promise < string >
(
=>
{
.
add
(
renderMarkdown
(
,
{
codeBlockRenderer
:
async
(
,
)
=>
{
resolve
(
)
;
return
simpleCodeBlockRenderer
(
,
)
;
}
}
)
)
;
}
)
;
.
strictEqual
(
,
'js'
)
;
}
)
;
}
)
;
suite
(
'ThemeIcons Support On'
,
(
)
=>
{
test
(
'render appendText'
,
(
)
=>
{
const
=
new
MarkdownString
(
undefined
,
{
:
true
}
)
;
.
appendText
(
'$(zap) $(not a theme icon) $(add)'
)
;
const
:
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <p>$(zap) $(not a theme icon) $(add)</p> `
)
;
}
)
;
test
(
'render appendMarkdown'
,
(
)
=>
{
const
=
new
MarkdownString
(
undefined
,
{
:
true
}
)
;
.
appendMarkdown
(
'$(zap) $(not a theme icon) $(add)'
)
;
const
:
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <p><span class="codicon codicon-zap"></span> $(not a theme icon) <span class="codicon codicon-add"></span></p> `
)
;
}
)
;
test
(
'render appendMarkdown with escaped icon'
,
(
)
=>
{
const
=
new
MarkdownString
(
undefined
,
{
:
true
}
)
;
.
appendMarkdown
(
'\\$(zap) $(not a theme icon) $(add)'
)
;
const
:
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <p>$(zap) $(not a theme icon) <span class="codicon codicon-add"></span></p> `
)
;
}
)
;
test
(
'render icon in link'
,
(
)
=>
{
const
=
new
MarkdownString
(
undefined
,
{
:
true
}
)
;
.
appendMarkdown
(
` [$(zap)-link](#link) `
)
;
const
:
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <p><a href="" title="#link" draggable="false" data-href="#link"><span class="codicon codicon-zap"></span>-link</a></p> `
)
;
}
)
;
test
(
'render icon in table'
,
(
)
=>
{
const
=
new
MarkdownString
(
undefined
,
{
:
true
}
)
;
.
appendMarkdown
(
`
| text | text |
|--------|----------------------|
| $(zap) | [$(zap)-link](#link) | `
)
;
const
:
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <table>
<thead>
<tr>
<th>text</th>
<th>text</th>
</tr>
</thead>
<tbody><tr>
<td><span class="codicon codicon-zap"></span></td>
<td><a href="" title="#link" draggable="false" data-href="#link"><span class="codicon codicon-zap"></span>-link</a></td>
</tr>
</tbody></table>
`
)
;
}
)
;
test
(
'render icon in <a> without href (#152170)'
,
(
)
=>
{
const
=
new
MarkdownString
(
undefined
,
{
:
true
,
:
true
}
)
;
.
appendMarkdown
(
` <a>$(sync)</a> `
)
;
const
:
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <p><span class="codicon codicon-sync"></span></p> `
)
;
}
)
;
}
)
;
suite
(
'ThemeIcons Support Off'
,
(
)
=>
{
test
(
'render appendText'
,
(
)
=>
{
const
=
new
MarkdownString
(
undefined
,
{
:
false
}
)
;
.
appendText
(
'$(zap) $(not a theme icon) $(add)'
)
;
const
:
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <p>$(zap) $(not a theme icon) $(add)</p> `
)
;
}
)
;
test
(
'render appendMarkdown with escaped icon'
,
(
)
=>
{
const
=
new
MarkdownString
(
undefined
,
{
:
false
}
)
;
.
appendMarkdown
(
'\\$(zap) $(not a theme icon) $(add)'
)
;
const
:
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <p>$(zap) $(not a theme icon) $(add)</p> `
)
;
}
)
;
}
)
;
suite
(
'Alerts'
,
(
)
=>
{
test
(
'Should render alert with data-severity attribute and icon'
,
(
)
=>
{
const
=
new
MarkdownString
(
'> [!NOTE]\n> This is a note alert'
,
{
:
true
}
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
;
const
=
.
querySelector
(
'blockquote[data-severity="note"]'
)
;
.
ok
(
,
'Should have blockquote with data-severity="note"'
)
;
.
ok
(
.
.
includes
(
'This is a note alert'
)
,
'Should contain alert text'
)
;
.
ok
(
.
.
includes
(
'codicon-info'
)
,
'Should contain info icon'
)
;
}
)
;
test
(
'Should render regular blockquote when supportAlertSyntax is disabled'
,
(
)
=>
{
const
=
new
MarkdownString
(
'> [!NOTE]\n> This should be a regular blockquote'
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
;
const
=
.
querySelector
(
'blockquote'
)
;
.
ok
(
,
'Should have blockquote'
)
;
.
strictEqual
(
?.
getAttribute
(
'data-severity'
)
,
null
,
'Should not have data-severity attribute'
)
;
.
ok
(
.
.
includes
(
'[!NOTE]'
)
,
'Should contain literal [!NOTE] text'
)
;
}
)
;
test
(
'Should not transform blockquotes without alert syntax'
,
(
)
=>
{
const
=
new
MarkdownString
(
'> This is a regular blockquote'
,
{
:
true
}
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
;
const
=
.
querySelector
(
'blockquote'
)
;
.
strictEqual
(
?.
getAttribute
(
'data-severity'
)
,
null
,
'Should not have data-severity attribute'
)
;
}
)
;
}
)
;
test
(
'npm Hover Run Script not working #90855'
,
function
(
)
{
const
:
=
JSON
.
parse
(
'{"value":"[Run Script](command:npm.runScriptFromHover?%7B%22documentUri%22%3A%7B%22%24mid%22%3A1%2C%22fsPath%22%3A%22c%3A%5C%5CUsers%5C%5Cjrieken%5C%5CCode%5C%5C_sample%5C%5Cfoo%5C%5Cpackage.json%22%2C%22_sep%22%3A1%2C%22external%22%3A%22file%3A%2F%2F%2Fc%253A%2FUsers%2Fjrieken%2FCode%2F_sample%2Ffoo%2Fpackage.json%22%2C%22path%22%3A%22%2Fc%3A%2FUsers%2Fjrieken%2FCode%2F_sample%2Ffoo%2Fpackage.json%22%2C%22scheme%22%3A%22file%22%7D%2C%22script%22%3A%22echo%22%7D \\"Run the script as a task\\")","supportThemeIcons":false,"isTrusted":true,"uris":{"__uri_e49443":{"$mid":1,"fsPath":"c:\\\\Users\\\\jrieken\\\\Code\\\\_sample\\\\foo\\\\package.json","_sep":1,"external":"file:///c%3A/Users/jrieken/Code/_sample/foo/package.json","path":"/c:/Users/jrieken/Code/_sample/foo/package.json","scheme":"file"},"command:npm.runScriptFromHover?%7B%22documentUri%22%3A%7B%22%24mid%22%3A1%2C%22fsPath%22%3A%22c%3A%5C%5CUsers%5C%5Cjrieken%5C%5CCode%5C%5C_sample%5C%5Cfoo%5C%5Cpackage.json%22%2C%22_sep%22%3A1%2C%22external%22%3A%22file%3A%2F%2F%2Fc%253A%2FUsers%2Fjrieken%2FCode%2F_sample%2Ffoo%2Fpackage.json%22%2C%22path%22%3A%22%2Fc%3A%2FUsers%2Fjrieken%2FCode%2F_sample%2Ffoo%2Fpackage.json%22%2C%22scheme%22%3A%22file%22%7D%2C%22script%22%3A%22echo%22%7D":{"$mid":1,"path":"npm.runScriptFromHover","scheme":"command","query":"{\\"documentUri\\":\\"__uri_e49443\\",\\"script\\":\\"echo\\"}"}}}'
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
;
const
=
.
querySelector
(
'a'
)
!
;
.
ok
(
)
;
.
ok
(
.
[
'href'
]
)
;
const
=
URI
.
parse
(
.
[
'href'
]
!
)
;
const
=
<
{
:
string
;
:
URI
}
>
parse
(
decodeURIComponent
(
.
)
)
;
.
ok
(
)
;
.
strictEqual
(
.
,
'echo'
)
;
.
ok
(
.
.
toString
(
)
.
startsWith
(
'file:///c%3A/'
)
)
;
}
)
;
test
(
'Should not render command links by default'
,
(
)
=>
{
const
=
new
MarkdownString
(
` [command1](command:doFoo) <a href="command:doFoo">command2</a> `
,
{
:
true
}
)
;
const
:
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <p>command1 command2</p> `
)
;
}
)
;
test
(
'Should render command links in trusted strings'
,
(
)
=>
{
const
=
new
MarkdownString
(
` [command1](command:doFoo) <a href="command:doFoo">command2</a> `
,
{
:
true
,
:
true
,
}
)
;
const
:
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <p><a href="" title="" draggable="false" data-href="command:doFoo">command1</a> <a href="" data-href="command:doFoo">command2</a></p> `
)
;
}
)
;
test
(
'Should remove relative links if there is no base url'
,
(
)
=>
{
const
=
new
MarkdownString
(
` [text](./foo) <a href="./bar">bar</a> `
,
{
:
true
,
:
true
,
}
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <p>text bar</p> `
)
;
}
)
;
test
(
'Should support relative links if baseurl is set'
,
(
)
=>
{
const
=
new
MarkdownString
(
` [text](./foo) <a href="./bar">bar</a> <img src="cat.gif"> `
,
{
:
true
,
:
true
,
}
)
;
.
=
URI
.
parse
(
'https://example.com/path/'
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <p><a href="" title="./foo" draggable="false" data-href="https://example.com/path/foo">text</a> <a href="" data-href="https://example.com/path/bar">bar</a> <img src="https://example.com/path/cat.gif"></p> `
)
;
}
)
;
suite
(
'Copy-safe hrefs'
,
(
)
=>
{
test
(
'keeps the real href only for targets that resolve elsewhere'
,
(
)
=>
{
const
=
new
MarkdownString
(
` [web](https://example.com/page) [mail](mailto:user@example.com) [run](command:doFoo) [file](file:///home/user/a.ts) [ref](http://_vscodecontentref_/0) `
,
{
:
true
}
)
;
const
=
.
add
(
renderMarkdown
(
,
{
actionHandler
:
(
)
=>
{
}
}
)
)
.
;
.
deepStrictEqual
(
Array
.
from
(
.
querySelectorAll
(
'a'
)
,
=>
[
.
getAttribute
(
'href'
)
,
.
getAttribute
(
'data-href'
)
,
.
getAttribute
(
'draggable'
)
]
)
,
[
[
'https://example.com/page'
,
'https://example.com/page'
,
'false'
]
,
[
'mailto:user@example.com'
,
'mailto:user@example.com'
,
'false'
]
,
[
''
,
'command:doFoo'
,
'false'
]
,
[
''
,
'file:///home/user/a.ts'
,
'false'
]
,
[
''
,
'http://_vscodecontentref_/0'
,
'false'
]
,
]
)
;
}
)
;
test
(
'leaves the href empty when nothing intercepts clicks'
,
(
)
=>
{
const
=
new
MarkdownString
(
` [web](https://example.com/page) `
,
{
}
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
.
querySelector
(
'a'
)
!
;
.
deepStrictEqual
(
[
.
getAttribute
(
'href'
)
,
.
getAttribute
(
'data-href'
)
]
,
[
''
,
'https://example.com/page'
]
)
;
}
)
;
test
(
'keeps the resolved href for relative links against an https baseUri'
,
(
)
=>
{
const
=
new
MarkdownString
(
` [text](./foo) `
,
{
:
true
}
)
;
.
=
URI
.
parse
(
'https://example.com/path/'
)
;
const
=
.
add
(
renderMarkdown
(
,
{
actionHandler
:
(
)
=>
{
}
}
)
)
.
.
querySelector
(
'a'
)
!
;
.
deepStrictEqual
(
[
.
getAttribute
(
'href'
)
,
.
getAttribute
(
'data-href'
)
]
,
[
'https://example.com/path/foo'
,
'https://example.com/path/foo'
]
)
;
}
)
;
}
)
;
test
(
'Should use decoded file path as title for file:// links'
,
(
)
=>
{
const
=
URI
.
file
(
'/home/user/project/lib.d.ts'
)
;
const
=
new
MarkdownString
(
` [log]( ${ fileUri. toString ( ) } ) `
,
{
}
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
;
const
=
.
querySelector
(
'a'
)
!
;
.
ok
(
)
;
.
strictEqual
(
.
,
.
)
;
}
)
;
test
(
'Should include fragment in title for file:// links with line numbers'
,
(
)
=>
{
const
=
URI
.
file
(
'/home/user/project/lib.d.ts'
)
;
const
=
new
MarkdownString
(
` [log]( ${ fileUri. toString ( ) } #L42) `
,
{
}
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
;
const
=
.
querySelector
(
'a'
)
!
;
.
ok
(
)
;
.
strictEqual
(
.
,
` ${ fileUri. fsPath} #L42 `
)
;
}
)
;
test
(
'Should not override explicit title for file:// links'
,
(
)
=>
{
const
=
URI
.
file
(
'/home/user/project/lib.d.ts'
)
;
const
=
new
MarkdownString
(
` [log]( ${ fileUri. toString ( ) } "Go to definition") `
,
{
}
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
;
const
=
.
querySelector
(
'a'
)
!
;
.
ok
(
)
;
.
strictEqual
(
.
,
'Go to definition'
)
;
}
)
;
suite
(
'PlaintextMarkdownRender'
,
(
)
=>
{
test
(
'test code, blockquote, heading, list, listitem, paragraph, table, tablerow, tablecell, strong, em, br, del, text are rendered plaintext'
,
(
)
=>
{
const
=
{
:
'`code`\n>quote\n# heading\n- list\n\ntable | table2\n--- | --- \none | two\n\n\nbo**ld**\n_italic_\n~~del~~\nsome text'
}
;
const
=
'code\nquote\nheading\nlist\n\ntable table2\none two\nbold\nitalic\ndel\nsome text'
;
const
:
string
=
renderAsPlaintext
(
)
;
.
strictEqual
(
,
)
;
}
)
;
test
(
'test html, hr, image, link are rendered plaintext'
,
(
)
=>
{
const
=
{
:
'<div>html</div>\n\n---\n\n[text](textLink)'
}
;
const
=
'text'
;
const
:
string
=
renderAsPlaintext
(
)
;
.
strictEqual
(
,
)
;
}
)
;
test
(
` Should not remove html inside of code blocks `
,
(
)
=>
{
const
=
{
:
[
'```html'
,
'<form>html</form>'
,
'```'
,
]
.
join
(
'\n'
)
}
;
const
=
[
'```'
,
'<form>html</form>'
,
'```'
,
]
.
join
(
'\n'
)
;
const
:
string
=
renderAsPlaintext
(
,
{
:
true
}
)
;
.
strictEqual
(
,
)
;
}
)
;
test
(
'does not double-escape entities inside code spans'
,
(
)
=>
{
.
strictEqual
(
renderAsPlaintext
(
{
:
'Run `tests & build`'
}
)
,
'Run tests & build'
)
;
.
strictEqual
(
renderAsPlaintext
(
{
:
'Use `<form>` tag'
}
)
,
'Use <form> tag'
)
;
}
)
;
test
(
'reduces inline syntax inside list items when omitMarkdownSyntax is set'
,
(
)
=>
{
const
=
{
:
'- Added [src/](/some/path/to/src)\n- Uses **bold** and `code`'
}
;
.
strictEqual
(
renderAsPlaintext
(
)
,
'Added [src/](/some/path/to/src)\n\nUses **bold** and `code`'
,
'default output is unchanged'
)
;
.
strictEqual
(
renderAsPlaintext
(
,
{
:
true
}
)
,
'Added src/\n\nUses bold and code'
)
;
}
)
;
test
(
'separates a nested list from the item holding it when omitMarkdownSyntax is set'
,
(
)
=>
{
const
=
{
:
'- outer\n - inner [link](/target)'
}
;
.
strictEqual
(
renderAsPlaintext
(
,
{
:
true
}
)
,
'outer\ninner link'
)
;
}
)
;
}
)
;
suite
(
'supportHtml'
,
(
)
=>
{
test
(
'supportHtml is disabled by default'
,
(
)
=>
{
const
=
new
MarkdownString
(
undefined
,
{
}
)
;
.
appendMarkdown
(
'a<b>b</b>c'
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <p>abc</p> `
)
;
}
)
;
test
(
'Renders html when supportHtml=true'
,
(
)
=>
{
const
=
new
MarkdownString
(
undefined
,
{
:
true
}
)
;
.
appendMarkdown
(
'a<b>b</b>c'
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <p>a<b>b</b>c</p> `
)
;
}
)
;
test
(
'Should not include scripts even when supportHtml=true'
,
(
)
=>
{
const
=
new
MarkdownString
(
undefined
,
{
:
true
}
)
;
.
appendMarkdown
(
'a<b onclick="alert(1)">b</b><script>alert(2)</script>c'
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <p>a<b>b</b>c</p> `
)
;
}
)
;
test
(
'Should not render html appended as text'
,
(
)
=>
{
const
=
new
MarkdownString
(
undefined
,
{
:
true
}
)
;
.
appendText
(
'a<b>b</b>c'
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <p>a<b>b</b>c</p> `
)
;
}
)
;
test
(
'Should render html images'
,
(
)
=>
{
if
(
)
{
return
;
}
const
=
new
MarkdownString
(
undefined
,
{
:
true
}
)
;
.
appendMarkdown
(
` <img src="http://example.com/cat.gif"> `
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <img src="http://example.com/cat.gif"> `
)
;
}
)
;
test
(
'Should render html images with file uri as same origin uri'
,
(
)
=>
{
if
(
)
{
return
;
}
const
=
new
MarkdownString
(
undefined
,
{
:
true
}
)
;
.
appendMarkdown
(
` <img src="file:///images/cat.gif"> `
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <img src="vscode-file://vscode-app/images/cat.gif"> `
)
;
}
)
;
test
(
'Should only allow checkbox inputs'
,
(
)
=>
{
const
=
new
MarkdownString
(
'text: <input type="text">\ncheckbox:<input type="checkbox">'
,
{
:
true
}
)
;
const
=
.
add
(
renderMarkdown
(
)
)
.
;
.
strictEqual
(
.
,
` <p>text: \ncheckbox:<input type="checkbox" disabled=""></p> `
)
;
}
)
;
}
)
;
suite
(
'fillInIncompleteTokens'
,
(
)
=>
{
function
ignoreRaw
(
...
:
.
[
]
[
]
)
:
void
{
.
forEach
(
=>
{
.
forEach
(
=>
.
=
''
)
;
}
)
;
}
const
=
'| a | b |\n| --- | --- |'
;
suite
(
'table'
,
(
)
=>
{
test
(
'complete table'
,
(
)
=>
{
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
equal
(
,
)
;
}
)
;
test
(
'full header only'
,
(
)
=>
{
const
=
'| a | b |'
;
const
=
.
.
lexer
(
)
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'full header only with trailing space'
,
(
)
=>
{
const
=
'| a | b | '
;
const
=
.
.
lexer
(
)
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
if
(
)
{
ignoreRaw
(
,
)
;
}
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'incomplete header'
,
(
)
=>
{
const
=
'| a | b'
;
const
=
.
.
lexer
(
)
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
if
(
)
{
ignoreRaw
(
,
)
;
}
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'incomplete header one column'
,
(
)
=>
{
const
=
'| a '
;
const
=
.
.
lexer
(
)
;
const
=
.
.
lexer
(
+
'|\n| --- |'
)
;
const
=
fillInIncompleteTokens
(
)
;
if
(
)
{
ignoreRaw
(
,
)
;
}
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'full header with extras'
,
(
)
=>
{
const
=
'| a **bold** | b _italics_ |'
;
const
=
.
.
lexer
(
)
;
const
=
.
.
lexer
(
+
'\n| --- | --- |'
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'full header with leading text'
,
(
)
=>
{
const
=
'here is a table\n| a | b |'
;
const
=
.
.
lexer
(
)
;
const
=
.
.
lexer
(
+
'\n| --- | --- |'
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'full header with leading other stuff'
,
(
)
=>
{
const
=
'```js\nconst xyz = 123;\n```\n| a | b |'
;
const
=
.
.
lexer
(
)
;
const
=
.
.
lexer
(
+
'\n| --- | --- |'
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'full header with incomplete separator'
,
(
)
=>
{
const
=
'| a | b |\n| ---'
;
const
=
.
.
lexer
(
)
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'full header with incomplete separator 2'
,
(
)
=>
{
const
=
'| a | b |\n| --- |'
;
const
=
.
.
lexer
(
)
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'full header with incomplete separator 3'
,
(
)
=>
{
const
=
'| a | b |\n|'
;
const
=
.
.
lexer
(
)
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'not a table'
,
(
)
=>
{
const
=
'| a | b |\nsome text'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'not a table 2'
,
(
)
=>
{
const
=
'| a | b |\n| --- |\nsome text'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
}
)
;
function
simpleMarkdownTestSuite
(
:
string
,
:
string
)
:
void
{
test
(
` incomplete ${ name} `
,
(
)
=>
{
const
=
` ${ delimiter} code `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
` complete ${ name} `
,
(
)
=>
{
const
=
` leading text ${ delimiter} code ${ delimiter} trailing text `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
` ${ name} with leading text `
,
(
)
=>
{
const
=
` some text and ${ delimiter} some code `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
` ${ name} with trailing space `
,
(
)
=>
{
const
=
` some text and ${ delimiter} some code `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
.
trimEnd
(
)
+
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
` single loose " ${ delimiter} " `
,
(
)
=>
{
const
=
` some text and ${ delimiter} by itself\nmore text here `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
` incomplete ${ name} after newline `
,
(
)
=>
{
const
=
` some text\nmore text here and ${ delimiter} text `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
` incomplete after complete ${ name} `
,
(
)
=>
{
const
=
` leading text ${ delimiter} code ${ delimiter} trailing text and ${ delimiter} another `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
` incomplete ${ name} in list `
,
(
)
=>
{
const
=
` - list item one\n- list item two and ${ delimiter} text `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
` incomplete ${ name} in asterisk list `
,
(
)
=>
{
const
=
` * list item one\n* list item two and ${ delimiter} text `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
` incomplete ${ name} in numbered list `
,
(
)
=>
{
const
=
` 1. list item one\n2. list item two and ${ delimiter} text `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
}
suite
(
'list'
,
(
)
=>
{
test
(
'list with complete codeblock'
,
(
)
=>
{
const
=
` -
\`\`\`js
let x = 1;
\`\`\`
- list item two
`
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
.
skip
(
'list with incomplete codeblock'
,
(
)
=>
{
const
=
` - list item one
\`\`\`js
let x = 1; `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'\n ```'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'list with subitems'
,
(
)
=>
{
const
=
` - hello
- sub item
- text
newline for some reason
`
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'ordered list with subitems'
,
(
)
=>
{
const
=
` 1. hello
- sub item
2. text
newline for some reason
`
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'list with stuff'
,
(
)
=>
{
const
=
` - list item one \`codespan\` **bold** [link](http://microsoft.com) more text `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'list with incomplete link text'
,
(
)
=>
{
const
=
` - list item one
- item two [link `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'](https://microsoft.com)'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'list with incomplete link target'
,
(
)
=>
{
const
=
` - list item one
- item two [link]( `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
')'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'ordered list with incomplete link target'
,
(
)
=>
{
const
=
` 1. list item one
2. item two [link]( `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
')'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'ordered list with extra whitespace'
,
(
)
=>
{
const
=
` 1. list item one
2. item two [link]( `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
')'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'list with extra whitespace'
,
(
)
=>
{
const
=
` - list item one
- item two [link]( `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
')'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'list with incomplete link with other stuff'
,
(
)
=>
{
const
=
` - list item one
- item two [\`link `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'\`](https://microsoft.com)'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'ordered list with incomplete link with other stuff'
,
(
)
=>
{
const
=
` 1. list item one
1. item two [\`link `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'\`](https://microsoft.com)'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'list with bold incomplete link target'
,
(
)
=>
{
const
=
` - list item one
- **[link](http://microsoft `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
')**'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'ordered list with bold incomplete link target'
,
(
)
=>
{
const
=
` 1. list item one
2. **[link](http://microsoft `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
')**'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'list with incomplete subitem'
,
(
)
=>
{
const
=
` 1. list item one
- `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
' '
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'list with incomplete nested subitem'
,
(
)
=>
{
const
=
` 1. list item one
- item 2
- `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
' '
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'text with start of list is not a heading'
,
(
)
=>
{
const
=
` hello\n- `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
' '
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'even more text with start of list is not a heading'
,
(
)
=>
{
const
=
` # hello\n\ntext\n- `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
' '
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
}
)
;
suite
(
'blockquote'
,
(
)
=>
{
test
(
'incomplete double star'
,
(
)
=>
{
const
=
'> **text'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'**'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'incomplete double star before trailing quote-only lines'
,
(
)
=>
{
const
=
'> **text\n>\n>'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
'> **text**\n>\n>'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'preserves reference links when completing inline tokens'
,
(
)
=>
{
const
=
'[id]: https://example.com\n\n> [label][id] **text'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'**'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
}
)
;
suite
(
'codespan'
,
(
)
=>
{
simpleMarkdownTestSuite
(
'codespan'
,
'`'
)
;
test
(
` backtick between letters `
,
(
)
=>
{
const
=
'a`b'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'`'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
` nested pattern `
,
(
)
=>
{
const
=
'sldkfjsd `abc __def__ ghi'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'`'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'codespan inside <body> wrapped markdown'
,
(
)
=>
{
const
=
'<body>\n\nCreated isolated worktree for branch `xyz\n\n</body>'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
'<body>\n\nCreated isolated worktree for branch `xyz`\n\n</body>'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
}
)
;
suite
(
'star'
,
(
)
=>
{
simpleMarkdownTestSuite
(
'star'
,
'*'
)
;
test
(
` star between letters `
,
(
)
=>
{
const
=
'sldkfjsd a*b'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'*'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
` nested pattern `
,
(
)
=>
{
const
=
'sldkfjsd *abc __def__ ghi'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'*'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
}
)
;
suite
(
'double star'
,
(
)
=>
{
simpleMarkdownTestSuite
(
'double star'
,
'**'
)
;
test
(
` double star between letters `
,
(
)
=>
{
const
=
'a**b'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'**'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
.
skip
(
` ending in doublestar `
,
(
)
=>
{
const
=
` some text and ** `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
.
trimEnd
(
)
+
'**'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
}
)
;
suite
(
'underscore'
,
(
)
=>
{
simpleMarkdownTestSuite
(
'underscore'
,
'_'
)
;
test
(
` underscore between letters `
,
(
)
=>
{
const
=
` this_not_italics `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
}
)
;
suite
(
'double underscore'
,
(
)
=>
{
simpleMarkdownTestSuite
(
'double underscore'
,
'__'
)
;
test
(
` double underscore between letters `
,
(
)
=>
{
const
=
` this__not__bold `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
}
)
;
suite
(
'link'
,
(
)
=>
{
test
(
'incomplete link text'
,
(
)
=>
{
const
=
'abc [text'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'](https://microsoft.com)'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'incomplete link target'
,
(
)
=>
{
const
=
'foo [text](http://microsoft'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
')'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'incomplete link target 2'
,
(
)
=>
{
const
=
'foo [text](http://microsoft.com'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
')'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'incomplete link target inside parentheses'
,
(
)
=>
{
const
=
'([text](http://microsoft.com'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
')'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'incomplete link target with extra stuff'
,
(
)
=>
{
const
=
'[before `text` after](http://microsoft.com'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
')'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'incomplete link target with extra stuff and incomplete arg'
,
(
)
=>
{
const
=
'[before `text` after](http://microsoft.com "more text '
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'")'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'incomplete link target with incomplete arg'
,
(
)
=>
{
const
=
'foo [text](http://microsoft.com "more text here '
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'")'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'incomplete link target with incomplete arg 2'
,
(
)
=>
{
const
=
'[text](command:vscode.openRelativePath "arg'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'")'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'incomplete link target with complete arg'
,
(
)
=>
{
const
=
'foo [text](http://microsoft.com "more text here"'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
')'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'link text with incomplete codespan'
,
(
)
=>
{
const
=
` text [\`codespan `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'`](https://microsoft.com)'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'link text with incomplete stuff'
,
(
)
=>
{
const
=
` text [more text \`codespan\` text **bold `
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'**](https://microsoft.com)'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'Looks like incomplete link target but isn\'t'
,
(
)
=>
{
const
=
'**bold** `codespan` text]('
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'incomplete link in list'
,
(
)
=>
{
const
=
'- [text'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'](https://microsoft.com)'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'incomplete link target inside bold'
,
(
)
=>
{
const
=
'**[text](http://microsoft'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
')**'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'incomplete link target with arg inside bold'
,
(
)
=>
{
const
=
'**[text](http://microsoft.com "more text '
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
const
=
.
.
lexer
(
+
'")**'
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'square brace between letters'
,
(
)
=>
{
const
=
'a[b'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'square brace on previous line'
,
(
)
=>
{
const
=
'text[\nmore text'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'square braces in text'
,
(
)
=>
{
const
=
'hello [what] is going on'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
test
(
'complete link'
,
(
)
=>
{
const
=
'text [link](http://microsoft.com)'
;
const
=
.
.
lexer
(
)
;
const
=
fillInIncompleteTokens
(
)
;
.
deepStrictEqual
(
,
)
;
}
)
;
}
)
;
}
)
;
}
)
;