github.com/elliott5/community@v0.14.1-0.20160709191136-823126fb026a/app/public/codemirror/mode/gfm/test.js (about) 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("fencedCodeBlocksNoTildes", 55 "~~~", 56 "foo", 57 "~~~"); 58 59 MT("taskListAsterisk", 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("taskListPlus", 67 "[variable-2 + []] foo]", // Invalid; must have space or x between [] 68 "[variable-2 + [ ]]bar]", // Invalid; must have space after ] 69 "[variable-2 + [x]]hello]", // Invalid; must have space after ] 70 "[variable-2 + ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links 71 " [variable-3 + ][property [x]]][variable-3 foo]"); // Valid; can be nested 72 73 MT("taskListDash", 74 "[variable-2 - []] foo]", // Invalid; must have space or x between [] 75 "[variable-2 - [ ]]bar]", // Invalid; must have space after ] 76 "[variable-2 - [x]]hello]", // Invalid; must have space after ] 77 "[variable-2 - ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links 78 " [variable-3 - ][property [x]]][variable-3 foo]"); // Valid; can be nested 79 80 MT("taskListNumber", 81 "[variable-2 1. []] foo]", // Invalid; must have space or x between [] 82 "[variable-2 2. [ ]]bar]", // Invalid; must have space after ] 83 "[variable-2 3. [x]]hello]", // Invalid; must have space after ] 84 "[variable-2 4. ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links 85 " [variable-3 1. ][property [x]]][variable-3 foo]"); // Valid; can be nested 86 87 MT("SHA", 88 "foo [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] bar"); 89 90 MT("SHAEmphasis", 91 "[em *foo ][em&link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]"); 92 93 MT("shortSHA", 94 "foo [link be6a8cc] bar"); 95 96 MT("tooShortSHA", 97 "foo be6a8c bar"); 98 99 MT("longSHA", 100 "foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar"); 101 102 MT("badSHA", 103 "foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar"); 104 105 MT("userSHA", 106 "foo [link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] hello"); 107 108 MT("userSHAEmphasis", 109 "[em *foo ][em&link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]"); 110 111 MT("userProjectSHA", 112 "foo [link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] world"); 113 114 MT("userProjectSHAEmphasis", 115 "[em *foo ][em&link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]"); 116 117 MT("num", 118 "foo [link #1] bar"); 119 120 MT("numEmphasis", 121 "[em *foo ][em&link #1][em *]"); 122 123 MT("badNum", 124 "foo #1bar hello"); 125 126 MT("userNum", 127 "foo [link bar#1] hello"); 128 129 MT("userNumEmphasis", 130 "[em *foo ][em&link bar#1][em *]"); 131 132 MT("userProjectNum", 133 "foo [link bar/hello#1] world"); 134 135 MT("userProjectNumEmphasis", 136 "[em *foo ][em&link bar/hello#1][em *]"); 137 138 MT("vanillaLink", 139 "foo [link http://www.example.com/] bar"); 140 141 MT("vanillaLinkNoScheme", 142 "foo [link www.example.com] bar"); 143 144 MT("vanillaLinkHttps", 145 "foo [link https://www.example.com/] bar"); 146 147 MT("vanillaLinkDataSchema", 148 "foo [link data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==] bar"); 149 150 MT("vanillaLinkPunctuation", 151 "foo [link http://www.example.com/]. bar"); 152 153 MT("vanillaLinkExtension", 154 "foo [link http://www.example.com/index.html] bar"); 155 156 MT("vanillaLinkEmphasis", 157 "foo [em *][em&link http://www.example.com/index.html][em *] bar"); 158 159 MT("notALink", 160 "foo asfd:asdf bar"); 161 162 MT("notALink", 163 "[comment ```css]", 164 "[tag foo] {[property color]:[keyword black];}", 165 "[comment ```][link http://www.example.com/]"); 166 167 MT("notALink", 168 "[comment ``foo `bar` http://www.example.com/``] hello"); 169 170 MT("notALink", 171 "[comment `foo]", 172 "[comment&link http://www.example.com/]", 173 "[comment `] foo", 174 "", 175 "[link http://www.example.com/]"); 176 177 MT("headerCodeBlockGithub", 178 "[header&header-1 # heading]", 179 "", 180 "[comment ```]", 181 "[comment code]", 182 "[comment ```]", 183 "", 184 "Commit: [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2]", 185 "Issue: [link #1]", 186 "Link: [link http://www.example.com/]"); 187 188 MT("strikethrough", 189 "[strikethrough ~~foo~~]"); 190 191 MT("strikethroughWithStartingSpace", 192 "~~ foo~~"); 193 194 MT("strikethroughUnclosedStrayTildes", 195 "[strikethrough ~~foo~~~]"); 196 197 MT("strikethroughUnclosedStrayTildes", 198 "[strikethrough ~~foo ~~]"); 199 200 MT("strikethroughUnclosedStrayTildes", 201 "[strikethrough ~~foo ~~ bar]"); 202 203 MT("strikethroughUnclosedStrayTildes", 204 "[strikethrough ~~foo ~~ bar~~]hello"); 205 206 MT("strikethroughOneLetter", 207 "[strikethrough ~~a~~]"); 208 209 MT("strikethroughWrapped", 210 "[strikethrough ~~foo]", 211 "[strikethrough foo~~]"); 212 213 MT("strikethroughParagraph", 214 "[strikethrough ~~foo]", 215 "", 216 "foo[strikethrough ~~bar]"); 217 218 MT("strikethroughEm", 219 "[strikethrough ~~foo][em&strikethrough *bar*][strikethrough ~~]"); 220 221 MT("strikethroughEm", 222 "[em *][em&strikethrough ~~foo~~][em *]"); 223 224 MT("strikethroughStrong", 225 "[strikethrough ~~][strong&strikethrough **foo**][strikethrough ~~]"); 226 227 MT("strikethroughStrong", 228 "[strong **][strong&strikethrough ~~foo~~][strong **]"); 229 230 })();