Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50675 views
1
// CodeMirror, copyright (c) by Marijn Haverbeke and others
2
// Distributed under an MIT license: http://codemirror.net/LICENSE
3
4
(function() {
5
var mode = CodeMirror.getMode({tabSize: 4}, "gfm");
6
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
7
var modeHighlightFormatting = CodeMirror.getMode({tabSize: 4}, {name: "gfm", highlightFormatting: true});
8
function FT(name) { test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1)); }
9
10
FT("codeBackticks",
11
"[comment&formatting&formatting-code `][comment foo][comment&formatting&formatting-code `]");
12
13
FT("doubleBackticks",
14
"[comment&formatting&formatting-code ``][comment foo ` bar][comment&formatting&formatting-code ``]");
15
16
FT("codeBlock",
17
"[comment&formatting&formatting-code-block ```css]",
18
"[tag foo]",
19
"[comment&formatting&formatting-code-block ```]");
20
21
FT("taskList",
22
"[variable-2&formatting&formatting-list&formatting-list-ul - ][meta&formatting&formatting-task [ ]]][variable-2 foo]",
23
"[variable-2&formatting&formatting-list&formatting-list-ul - ][property&formatting&formatting-task [x]]][variable-2 foo]");
24
25
FT("formatting_strikethrough",
26
"[strikethrough&formatting&formatting-strikethrough ~~][strikethrough foo][strikethrough&formatting&formatting-strikethrough ~~]");
27
28
FT("formatting_strikethrough",
29
"foo [strikethrough&formatting&formatting-strikethrough ~~][strikethrough bar][strikethrough&formatting&formatting-strikethrough ~~]");
30
31
MT("emInWordAsterisk",
32
"foo[em *bar*]hello");
33
34
MT("emInWordUnderscore",
35
"foo_bar_hello");
36
37
MT("emStrongUnderscore",
38
"[strong __][em&strong _foo__][em _] bar");
39
40
MT("fencedCodeBlocks",
41
"[comment ```]",
42
"[comment foo]",
43
"",
44
"[comment ```]",
45
"bar");
46
47
MT("fencedCodeBlockModeSwitching",
48
"[comment ```javascript]",
49
"[variable foo]",
50
"",
51
"[comment ```]",
52
"bar");
53
54
MT("taskListAsterisk",
55
"[variable-2 * []] foo]", // Invalid; must have space or x between []
56
"[variable-2 * [ ]]bar]", // Invalid; must have space after ]
57
"[variable-2 * [x]]hello]", // Invalid; must have space after ]
58
"[variable-2 * ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
59
" [variable-3 * ][property [x]]][variable-3 foo]"); // Valid; can be nested
60
61
MT("taskListPlus",
62
"[variable-2 + []] foo]", // Invalid; must have space or x between []
63
"[variable-2 + [ ]]bar]", // Invalid; must have space after ]
64
"[variable-2 + [x]]hello]", // Invalid; must have space after ]
65
"[variable-2 + ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
66
" [variable-3 + ][property [x]]][variable-3 foo]"); // Valid; can be nested
67
68
MT("taskListDash",
69
"[variable-2 - []] foo]", // Invalid; must have space or x between []
70
"[variable-2 - [ ]]bar]", // Invalid; must have space after ]
71
"[variable-2 - [x]]hello]", // Invalid; must have space after ]
72
"[variable-2 - ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
73
" [variable-3 - ][property [x]]][variable-3 foo]"); // Valid; can be nested
74
75
MT("taskListNumber",
76
"[variable-2 1. []] foo]", // Invalid; must have space or x between []
77
"[variable-2 2. [ ]]bar]", // Invalid; must have space after ]
78
"[variable-2 3. [x]]hello]", // Invalid; must have space after ]
79
"[variable-2 4. ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
80
" [variable-3 1. ][property [x]]][variable-3 foo]"); // Valid; can be nested
81
82
MT("SHA",
83
"foo [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] bar");
84
85
MT("SHAEmphasis",
86
"[em *foo ][em&link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]");
87
88
MT("shortSHA",
89
"foo [link be6a8cc] bar");
90
91
MT("tooShortSHA",
92
"foo be6a8c bar");
93
94
MT("longSHA",
95
"foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar");
96
97
MT("badSHA",
98
"foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar");
99
100
MT("userSHA",
101
"foo [link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] hello");
102
103
MT("userSHAEmphasis",
104
"[em *foo ][em&link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]");
105
106
MT("userProjectSHA",
107
"foo [link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] world");
108
109
MT("userProjectSHAEmphasis",
110
"[em *foo ][em&link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]");
111
112
MT("num",
113
"foo [link #1] bar");
114
115
MT("numEmphasis",
116
"[em *foo ][em&link #1][em *]");
117
118
MT("badNum",
119
"foo #1bar hello");
120
121
MT("userNum",
122
"foo [link bar#1] hello");
123
124
MT("userNumEmphasis",
125
"[em *foo ][em&link bar#1][em *]");
126
127
MT("userProjectNum",
128
"foo [link bar/hello#1] world");
129
130
MT("userProjectNumEmphasis",
131
"[em *foo ][em&link bar/hello#1][em *]");
132
133
MT("vanillaLink",
134
"foo [link http://www.example.com/] bar");
135
136
MT("vanillaLinkPunctuation",
137
"foo [link http://www.example.com/]. bar");
138
139
MT("vanillaLinkExtension",
140
"foo [link http://www.example.com/index.html] bar");
141
142
MT("vanillaLinkEmphasis",
143
"foo [em *][em&link http://www.example.com/index.html][em *] bar");
144
145
MT("notALink",
146
"[comment ```css]",
147
"[tag foo] {[property color]:[keyword black];}",
148
"[comment ```][link http://www.example.com/]");
149
150
MT("notALink",
151
"[comment ``foo `bar` http://www.example.com/``] hello");
152
153
MT("notALink",
154
"[comment `foo]",
155
"[link http://www.example.com/]",
156
"[comment `foo]",
157
"",
158
"[link http://www.example.com/]");
159
160
MT("headerCodeBlockGithub",
161
"[header&header-1 # heading]",
162
"",
163
"[comment ```]",
164
"[comment code]",
165
"[comment ```]",
166
"",
167
"Commit: [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2]",
168
"Issue: [link #1]",
169
"Link: [link http://www.example.com/]");
170
171
MT("strikethrough",
172
"[strikethrough ~~foo~~]");
173
174
MT("strikethroughWithStartingSpace",
175
"~~ foo~~");
176
177
MT("strikethroughUnclosedStrayTildes",
178
"[strikethrough ~~foo~~~]");
179
180
MT("strikethroughUnclosedStrayTildes",
181
"[strikethrough ~~foo ~~]");
182
183
MT("strikethroughUnclosedStrayTildes",
184
"[strikethrough ~~foo ~~ bar]");
185
186
MT("strikethroughUnclosedStrayTildes",
187
"[strikethrough ~~foo ~~ bar~~]hello");
188
189
MT("strikethroughOneLetter",
190
"[strikethrough ~~a~~]");
191
192
MT("strikethroughWrapped",
193
"[strikethrough ~~foo]",
194
"[strikethrough foo~~]");
195
196
MT("strikethroughParagraph",
197
"[strikethrough ~~foo]",
198
"",
199
"foo[strikethrough ~~bar]");
200
201
MT("strikethroughEm",
202
"[strikethrough ~~foo][em&strikethrough *bar*][strikethrough ~~]");
203
204
MT("strikethroughEm",
205
"[em *][em&strikethrough ~~foo~~][em *]");
206
207
MT("strikethroughStrong",
208
"[strikethrough ~~][strong&strikethrough **foo**][strikethrough ~~]");
209
210
MT("strikethroughStrong",
211
"[strong **][strong&strikethrough ~~foo~~][strong **]");
212
213
})();
214
215