test.min.js (9437B)
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}, 'textile'); 6 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } 7 8 MT('simpleParagraphs', 9 'Some text.', 10 '', 11 'Some more text.'); 12 13 /* 14 * Phrase Modifiers 15 */ 16 17 MT('em', 18 'foo [em _bar_]'); 19 20 MT('emBoogus', 21 'code_mirror'); 22 23 MT('strong', 24 'foo [strong *bar*]'); 25 26 MT('strongBogus', 27 '3 * 3 = 9'); 28 29 MT('italic', 30 'foo [em __bar__]'); 31 32 MT('italicBogus', 33 'code__mirror'); 34 35 MT('bold', 36 'foo [strong **bar**]'); 37 38 MT('boldBogus', 39 '3 ** 3 = 27'); 40 41 MT('simpleLink', 42 '[link "CodeMirror":http://codemirror.net]'); 43 44 MT('referenceLink', 45 '[link "CodeMirror":code_mirror]', 46 'Normal Text.', 47 '[link [[code_mirror]]http://codemirror.net]'); 48 49 MT('footCite', 50 'foo bar[qualifier [[1]]]'); 51 52 MT('footCiteBogus', 53 'foo bar[[1a2]]'); 54 55 MT('special-characters', 56 'Registered [tag (r)], ' + 57 'Trademark [tag (tm)], and ' + 58 'Copyright [tag (c)] 2008'); 59 60 MT('cite', 61 "A book is [keyword ??The Count of Monte Cristo??] by Dumas."); 62 63 MT('additionAndDeletion', 64 'The news networks declared [negative -Al Gore-] ' + 65 '[positive +George W. Bush+] the winner in Florida.'); 66 67 MT('subAndSup', 68 'f(x, n) = log [builtin ~4~] x [builtin ^n^]'); 69 70 MT('spanAndCode', 71 'A [quote %span element%] and [atom @code element@]'); 72 73 MT('spanBogus', 74 'Percentage 25% is not a span.'); 75 76 MT('citeBogus', 77 'Question? is not a citation.'); 78 79 MT('codeBogus', 80 'user@example.com'); 81 82 MT('subBogus', 83 '~username'); 84 85 MT('supBogus', 86 'foo ^ bar'); 87 88 MT('deletionBogus', 89 '3 - 3 = 0'); 90 91 MT('additionBogus', 92 '3 + 3 = 6'); 93 94 MT('image', 95 'An image: [string !http://www.example.com/image.png!]'); 96 97 MT('imageWithAltText', 98 'An image: [string !http://www.example.com/image.png (Alt Text)!]'); 99 100 MT('imageWithUrl', 101 'An image: [string !http://www.example.com/image.png!:http://www.example.com/]'); 102 103 /* 104 * Headers 105 */ 106 107 MT('h1', 108 '[header&header-1 h1. foo]'); 109 110 MT('h2', 111 '[header&header-2 h2. foo]'); 112 113 MT('h3', 114 '[header&header-3 h3. foo]'); 115 116 MT('h4', 117 '[header&header-4 h4. foo]'); 118 119 MT('h5', 120 '[header&header-5 h5. foo]'); 121 122 MT('h6', 123 '[header&header-6 h6. foo]'); 124 125 MT('h7Bogus', 126 'h7. foo'); 127 128 MT('multipleHeaders', 129 '[header&header-1 h1. Heading 1]', 130 '', 131 'Some text.', 132 '', 133 '[header&header-2 h2. Heading 2]', 134 '', 135 'More text.'); 136 137 MT('h1inline', 138 '[header&header-1 h1. foo ][header&header-1&em _bar_][header&header-1 baz]'); 139 140 /* 141 * Lists 142 */ 143 144 MT('ul', 145 'foo', 146 'bar', 147 '', 148 '[variable-2 * foo]', 149 '[variable-2 * bar]'); 150 151 MT('ulNoBlank', 152 'foo', 153 'bar', 154 '[variable-2 * foo]', 155 '[variable-2 * bar]'); 156 157 MT('ol', 158 'foo', 159 'bar', 160 '', 161 '[variable-2 # foo]', 162 '[variable-2 # bar]'); 163 164 MT('olNoBlank', 165 'foo', 166 'bar', 167 '[variable-2 # foo]', 168 '[variable-2 # bar]'); 169 170 MT('ulFormatting', 171 '[variable-2 * ][variable-2&em _foo_][variable-2 bar]', 172 '[variable-2 * ][variable-2&strong *][variable-2&em&strong _foo_]' + 173 '[variable-2&strong *][variable-2 bar]', 174 '[variable-2 * ][variable-2&strong *foo*][variable-2 bar]'); 175 176 MT('olFormatting', 177 '[variable-2 # ][variable-2&em _foo_][variable-2 bar]', 178 '[variable-2 # ][variable-2&strong *][variable-2&em&strong _foo_]' + 179 '[variable-2&strong *][variable-2 bar]', 180 '[variable-2 # ][variable-2&strong *foo*][variable-2 bar]'); 181 182 MT('ulNested', 183 '[variable-2 * foo]', 184 '[variable-3 ** bar]', 185 '[keyword *** bar]', 186 '[variable-2 **** bar]', 187 '[variable-3 ** bar]'); 188 189 MT('olNested', 190 '[variable-2 # foo]', 191 '[variable-3 ## bar]', 192 '[keyword ### bar]', 193 '[variable-2 #### bar]', 194 '[variable-3 ## bar]'); 195 196 MT('ulNestedWithOl', 197 '[variable-2 * foo]', 198 '[variable-3 ## bar]', 199 '[keyword *** bar]', 200 '[variable-2 #### bar]', 201 '[variable-3 ** bar]'); 202 203 MT('olNestedWithUl', 204 '[variable-2 # foo]', 205 '[variable-3 ** bar]', 206 '[keyword ### bar]', 207 '[variable-2 **** bar]', 208 '[variable-3 ## bar]'); 209 210 MT('definitionList', 211 '[number - coffee := Hot ][number&em _and_][number black]', 212 '', 213 'Normal text.'); 214 215 MT('definitionListSpan', 216 '[number - coffee :=]', 217 '', 218 '[number Hot ][number&em _and_][number black =:]', 219 '', 220 'Normal text.'); 221 222 MT('boo', 223 '[number - dog := woof woof]', 224 '[number - cat := meow meow]', 225 '[number - whale :=]', 226 '[number Whale noises.]', 227 '', 228 '[number Also, ][number&em _splashing_][number . =:]'); 229 230 /* 231 * Attributes 232 */ 233 234 MT('divWithAttribute', 235 '[punctuation div][punctuation&attribute (#my-id)][punctuation . foo bar]'); 236 237 MT('divWithAttributeAnd2emRightPadding', 238 '[punctuation div][punctuation&attribute (#my-id)((][punctuation . foo bar]'); 239 240 MT('divWithClassAndId', 241 '[punctuation div][punctuation&attribute (my-class#my-id)][punctuation . foo bar]'); 242 243 MT('paragraphWithCss', 244 'p[attribute {color:red;}]. foo bar'); 245 246 MT('paragraphNestedStyles', 247 'p. [strong *foo ][strong&em _bar_][strong *]'); 248 249 MT('paragraphWithLanguage', 250 'p[attribute [[fr]]]. Parlez-vous français?'); 251 252 MT('paragraphLeftAlign', 253 'p[attribute <]. Left'); 254 255 MT('paragraphRightAlign', 256 'p[attribute >]. Right'); 257 258 MT('paragraphRightAlign', 259 'p[attribute =]. Center'); 260 261 MT('paragraphJustified', 262 'p[attribute <>]. Justified'); 263 264 MT('paragraphWithLeftIndent1em', 265 'p[attribute (]. Left'); 266 267 MT('paragraphWithRightIndent1em', 268 'p[attribute )]. Right'); 269 270 MT('paragraphWithLeftIndent2em', 271 'p[attribute ((]. Left'); 272 273 MT('paragraphWithRightIndent2em', 274 'p[attribute ))]. Right'); 275 276 MT('paragraphWithLeftIndent3emRightIndent2em', 277 'p[attribute ((())]. Right'); 278 279 MT('divFormatting', 280 '[punctuation div. ][punctuation&strong *foo ]' + 281 '[punctuation&strong&em _bar_][punctuation&strong *]'); 282 283 MT('phraseModifierAttributes', 284 'p[attribute (my-class)]. This is a paragraph that has a class and' + 285 ' this [em _][em&attribute (#special-phrase)][em emphasized phrase_]' + 286 ' has an id.'); 287 288 MT('linkWithClass', 289 '[link "(my-class). This is a link with class":http://redcloth.org]'); 290 291 /* 292 * Layouts 293 */ 294 295 MT('paragraphLayouts', 296 'p. This is one paragraph.', 297 '', 298 'p. This is another.'); 299 300 MT('div', 301 '[punctuation div. foo bar]'); 302 303 MT('pre', 304 '[operator pre. Text]'); 305 306 MT('bq.', 307 '[bracket bq. foo bar]', 308 '', 309 'Normal text.'); 310 311 MT('footnote', 312 '[variable fn123. foo ][variable&strong *bar*]'); 313 314 /* 315 * Spanning Layouts 316 */ 317 318 MT('bq..ThenParagraph', 319 '[bracket bq.. foo bar]', 320 '', 321 '[bracket More quote.]', 322 'p. Normal Text'); 323 324 MT('bq..ThenH1', 325 '[bracket bq.. foo bar]', 326 '', 327 '[bracket More quote.]', 328 '[header&header-1 h1. Header Text]'); 329 330 MT('bc..ThenParagraph', 331 '[atom bc.. # Some ruby code]', 332 '[atom obj = {foo: :bar}]', 333 '[atom puts obj]', 334 '', 335 '[atom obj[[:love]] = "*love*"]', 336 '[atom puts obj.love.upcase]', 337 '', 338 'p. Normal text.'); 339 340 MT('fn1..ThenParagraph', 341 '[variable fn1.. foo bar]', 342 '', 343 '[variable More.]', 344 'p. Normal Text'); 345 346 MT('pre..ThenParagraph', 347 '[operator pre.. foo bar]', 348 '', 349 '[operator More.]', 350 'p. Normal Text'); 351 352 /* 353 * Tables 354 */ 355 356 MT('table', 357 '[variable-3&operator |_. name |_. age|]', 358 '[variable-3 |][variable-3&strong *Walter*][variable-3 | 5 |]', 359 '[variable-3 |Florence| 6 |]', 360 '', 361 'p. Normal text.'); 362 363 MT('tableWithAttributes', 364 '[variable-3&operator |_. name |_. age|]', 365 '[variable-3 |][variable-3&attribute /2.][variable-3 Jim |]', 366 '[variable-3 |][variable-3&attribute \\2{color: red}.][variable-3 Sam |]'); 367 368 /* 369 * HTML 370 */ 371 372 MT('html', 373 '[comment <div id="wrapper">]', 374 '[comment <section id="introduction">]', 375 '', 376 '[header&header-1 h1. Welcome]', 377 '', 378 '[variable-2 * Item one]', 379 '[variable-2 * Item two]', 380 '', 381 '[comment <a href="http://example.com">Example</a>]', 382 '', 383 '[comment </section>]', 384 '[comment </div>]'); 385 386 MT('inlineHtml', 387 'I can use HTML directly in my [comment <span class="youbetcha">Textile</span>].'); 388 389 /* 390 * No-Textile 391 */ 392 393 MT('notextile', 394 '[string-2 notextile. *No* formatting]'); 395 396 MT('notextileInline', 397 'Use [string-2 ==*asterisks*==] for [strong *strong*] text.'); 398 399 MT('notextileWithPre', 400 '[operator pre. *No* formatting]'); 401 402 MT('notextileWithSpanningPre', 403 '[operator pre.. *No* formatting]', 404 '', 405 '[operator *No* formatting]'); 406 407 /* Only toggling phrases between non-word chars. */ 408 409 MT('phrase-in-word', 410 'foo_bar_baz'); 411 412 MT('phrase-non-word', 413 '[negative -x-] aaa-bbb ccc-ddd [negative -eee-] fff [negative -ggg-]'); 414 415 MT('phrase-lone-dash', 416 'foo - bar - baz'); 417 })();