Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
malwaredllc
GitHub Repository: malwaredllc/byob
Path: blob/master/web-gui/buildyourownbotnet/assets/js/codemirror/mode/gfm/test.js
1293 views
1
(function() {
2
var mode = CodeMirror.getMode({tabSize: 4}, "gfm");
3
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
4
var modeHighlightFormatting = CodeMirror.getMode({tabSize: 4}, {name: "gfm", highlightFormatting: true});
5
function FT(name) { test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1)); }
6
7
FT("codeBackticks",
8
"[comment&formatting&formatting-code `][comment foo][comment&formatting&formatting-code `]");
9
10
FT("doubleBackticks",
11
"[comment&formatting&formatting-code ``][comment foo ` bar][comment&formatting&formatting-code ``]");
12
13
FT("codeBlock",
14
"[comment&formatting&formatting-code-block ```css]",
15
"[tag foo]",
16
"[comment&formatting&formatting-code-block ```]");
17
18
FT("taskList",
19
"[variable-2&formatting&formatting-list&formatting-list-ul - ][meta&formatting&formatting-task [ ]]][variable-2 foo]",
20
"[variable-2&formatting&formatting-list&formatting-list-ul - ][property&formatting&formatting-task [x]]][variable-2 foo]");
21
22
MT("emInWordAsterisk",
23
"foo[em *bar*]hello");
24
25
MT("emInWordUnderscore",
26
"foo_bar_hello");
27
28
MT("emStrongUnderscore",
29
"[strong __][em&strong _foo__][em _] bar");
30
31
MT("fencedCodeBlocks",
32
"[comment ```]",
33
"[comment foo]",
34
"",
35
"[comment ```]",
36
"bar");
37
38
MT("fencedCodeBlockModeSwitching",
39
"[comment ```javascript]",
40
"[variable foo]",
41
"",
42
"[comment ```]",
43
"bar");
44
45
MT("taskListAsterisk",
46
"[variable-2 * []] foo]", // Invalid; must have space or x between []
47
"[variable-2 * [ ]]bar]", // Invalid; must have space after ]
48
"[variable-2 * [x]]hello]", // Invalid; must have space after ]
49
"[variable-2 * ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
50
" [variable-3 * ][property [x]]][variable-3 foo]"); // Valid; can be nested
51
52
MT("taskListPlus",
53
"[variable-2 + []] foo]", // Invalid; must have space or x between []
54
"[variable-2 + [ ]]bar]", // Invalid; must have space after ]
55
"[variable-2 + [x]]hello]", // Invalid; must have space after ]
56
"[variable-2 + ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
57
" [variable-3 + ][property [x]]][variable-3 foo]"); // Valid; can be nested
58
59
MT("taskListDash",
60
"[variable-2 - []] foo]", // Invalid; must have space or x between []
61
"[variable-2 - [ ]]bar]", // Invalid; must have space after ]
62
"[variable-2 - [x]]hello]", // Invalid; must have space after ]
63
"[variable-2 - ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
64
" [variable-3 - ][property [x]]][variable-3 foo]"); // Valid; can be nested
65
66
MT("taskListNumber",
67
"[variable-2 1. []] foo]", // Invalid; must have space or x between []
68
"[variable-2 2. [ ]]bar]", // Invalid; must have space after ]
69
"[variable-2 3. [x]]hello]", // Invalid; must have space after ]
70
"[variable-2 4. ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
71
" [variable-3 1. ][property [x]]][variable-3 foo]"); // Valid; can be nested
72
73
MT("SHA",
74
"foo [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] bar");
75
76
MT("shortSHA",
77
"foo [link be6a8cc] bar");
78
79
MT("tooShortSHA",
80
"foo be6a8c bar");
81
82
MT("longSHA",
83
"foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar");
84
85
MT("badSHA",
86
"foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar");
87
88
MT("userSHA",
89
"foo [link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] hello");
90
91
MT("userProjectSHA",
92
"foo [link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] world");
93
94
MT("num",
95
"foo [link #1] bar");
96
97
MT("badNum",
98
"foo #1bar hello");
99
100
MT("userNum",
101
"foo [link bar#1] hello");
102
103
MT("userProjectNum",
104
"foo [link bar/hello#1] world");
105
106
MT("vanillaLink",
107
"foo [link http://www.example.com/] bar");
108
109
MT("vanillaLinkPunctuation",
110
"foo [link http://www.example.com/]. bar");
111
112
MT("vanillaLinkExtension",
113
"foo [link http://www.example.com/index.html] bar");
114
115
MT("notALink",
116
"[comment ```css]",
117
"[tag foo] {[property color]:[keyword black];}",
118
"[comment ```][link http://www.example.com/]");
119
120
MT("notALink",
121
"[comment ``foo `bar` http://www.example.com/``] hello");
122
123
MT("notALink",
124
"[comment `foo]",
125
"[link http://www.example.com/]",
126
"[comment `foo]",
127
"",
128
"[link http://www.example.com/]");
129
})();
130
131