all repos — NoPaste @ de062991ccdf763b2091f26873047685f9c0c977

Resurrected - The PussTheCat.org fork of NoPaste

scripts/CodeMirror/mode/gfm/test.js (view raw)

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