test.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. (function() {
  2. var mode = CodeMirror.getMode({tabSize: 4}, "markdown");
  3. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  4. var modeHighlightFormatting = CodeMirror.getMode({tabSize: 4}, {name: "markdown", highlightFormatting: true});
  5. function FT(name) { test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1)); }
  6. FT("formatting_emAsterisk",
  7. "[em&formatting&formatting-em *][em foo][em&formatting&formatting-em *]");
  8. FT("formatting_emUnderscore",
  9. "[em&formatting&formatting-em _][em foo][em&formatting&formatting-em _]");
  10. FT("formatting_strongAsterisk",
  11. "[strong&formatting&formatting-strong **][strong foo][strong&formatting&formatting-strong **]");
  12. FT("formatting_strongUnderscore",
  13. "[strong&formatting&formatting-strong __][strong foo][strong&formatting&formatting-strong __]");
  14. FT("formatting_codeBackticks",
  15. "[comment&formatting&formatting-code `][comment foo][comment&formatting&formatting-code `]");
  16. FT("formatting_doubleBackticks",
  17. "[comment&formatting&formatting-code ``][comment foo ` bar][comment&formatting&formatting-code ``]");
  18. FT("formatting_atxHeader",
  19. "[header&header-1&formatting&formatting-header&formatting-header-1 #][header&header-1 foo # bar ][header&header-1&formatting&formatting-header&formatting-header-1 #]");
  20. FT("formatting_setextHeader",
  21. "foo",
  22. "[header&header-1&formatting&formatting-header&formatting-header-1 =]");
  23. FT("formatting_blockquote",
  24. "[quote&quote-1&formatting&formatting-quote&formatting-quote-1 > ][quote&quote-1 foo]");
  25. FT("formatting_list",
  26. "[variable-2&formatting&formatting-list&formatting-list-ul - ][variable-2 foo]");
  27. FT("formatting_list",
  28. "[variable-2&formatting&formatting-list&formatting-list-ol 1. ][variable-2 foo]");
  29. FT("formatting_link",
  30. "[link&formatting&formatting-link [][link foo][link&formatting&formatting-link ]]][string&formatting&formatting-link-string (][string http://example.com/][string&formatting&formatting-link-string )]");
  31. FT("formatting_linkReference",
  32. "[link&formatting&formatting-link [][link foo][link&formatting&formatting-link ]]][string&formatting&formatting-link-string [][string bar][string&formatting&formatting-link-string ]]]",
  33. "[link&formatting&formatting-link [][link bar][link&formatting&formatting-link ]]:] [string http://example.com/]");
  34. FT("formatting_linkWeb",
  35. "[link&formatting&formatting-link <][link http://example.com/][link&formatting&formatting-link >]");
  36. FT("formatting_linkEmail",
  37. "[link&formatting&formatting-link <][link user@example.com][link&formatting&formatting-link >]");
  38. FT("formatting_escape",
  39. "[formatting&formatting-escape \\]*");
  40. MT("plainText",
  41. "foo");
  42. // Don't style single trailing space
  43. MT("trailingSpace1",
  44. "foo ");
  45. // Two or more trailing spaces should be styled with line break character
  46. MT("trailingSpace2",
  47. "foo[trailing-space-a ][trailing-space-new-line ]");
  48. MT("trailingSpace3",
  49. "foo[trailing-space-a ][trailing-space-b ][trailing-space-new-line ]");
  50. MT("trailingSpace4",
  51. "foo[trailing-space-a ][trailing-space-b ][trailing-space-a ][trailing-space-new-line ]");
  52. // Code blocks using 4 spaces (regardless of CodeMirror.tabSize value)
  53. MT("codeBlocksUsing4Spaces",
  54. " [comment foo]");
  55. // Code blocks using 4 spaces with internal indentation
  56. MT("codeBlocksUsing4SpacesIndentation",
  57. " [comment bar]",
  58. " [comment hello]",
  59. " [comment world]",
  60. " [comment foo]",
  61. "bar");
  62. // Code blocks using 4 spaces with internal indentation
  63. MT("codeBlocksUsing4SpacesIndentation",
  64. " foo",
  65. " [comment bar]",
  66. " [comment hello]",
  67. " [comment world]");
  68. // Code blocks using 1 tab (regardless of CodeMirror.indentWithTabs value)
  69. MT("codeBlocksUsing1Tab",
  70. "\t[comment foo]");
  71. // Inline code using backticks
  72. MT("inlineCodeUsingBackticks",
  73. "foo [comment `bar`]");
  74. // Block code using single backtick (shouldn't work)
  75. MT("blockCodeSingleBacktick",
  76. "[comment `]",
  77. "foo",
  78. "[comment `]");
  79. // Unclosed backticks
  80. // Instead of simply marking as CODE, it would be nice to have an
  81. // incomplete flag for CODE, that is styled slightly different.
  82. MT("unclosedBackticks",
  83. "foo [comment `bar]");
  84. // Per documentation: "To include a literal backtick character within a
  85. // code span, you can use multiple backticks as the opening and closing
  86. // delimiters"
  87. MT("doubleBackticks",
  88. "[comment ``foo ` bar``]");
  89. // Tests based on Dingus
  90. // http://daringfireball.net/projects/markdown/dingus
  91. //
  92. // Multiple backticks within an inline code block
  93. MT("consecutiveBackticks",
  94. "[comment `foo```bar`]");
  95. // Multiple backticks within an inline code block with a second code block
  96. MT("consecutiveBackticks",
  97. "[comment `foo```bar`] hello [comment `world`]");
  98. // Unclosed with several different groups of backticks
  99. MT("unclosedBackticks",
  100. "[comment ``foo ``` bar` hello]");
  101. // Closed with several different groups of backticks
  102. MT("closedBackticks",
  103. "[comment ``foo ``` bar` hello``] world");
  104. // atx headers
  105. // http://daringfireball.net/projects/markdown/syntax#header
  106. MT("atxH1",
  107. "[header&header-1 # foo]");
  108. MT("atxH2",
  109. "[header&header-2 ## foo]");
  110. MT("atxH3",
  111. "[header&header-3 ### foo]");
  112. MT("atxH4",
  113. "[header&header-4 #### foo]");
  114. MT("atxH5",
  115. "[header&header-5 ##### foo]");
  116. MT("atxH6",
  117. "[header&header-6 ###### foo]");
  118. // H6 - 7x '#' should still be H6, per Dingus
  119. // http://daringfireball.net/projects/markdown/dingus
  120. MT("atxH6NotH7",
  121. "[header&header-6 ####### foo]");
  122. // Inline styles should be parsed inside headers
  123. MT("atxH1inline",
  124. "[header&header-1 # foo ][header&header-1&em *bar*]");
  125. // Setext headers - H1, H2
  126. // Per documentation, "Any number of underlining =’s or -’s will work."
  127. // http://daringfireball.net/projects/markdown/syntax#header
  128. // Ideally, the text would be marked as `header` as well, but this is
  129. // not really feasible at the moment. So, instead, we're testing against
  130. // what works today, to avoid any regressions.
  131. //
  132. // Check if single underlining = works
  133. MT("setextH1",
  134. "foo",
  135. "[header&header-1 =]");
  136. // Check if 3+ ='s work
  137. MT("setextH1",
  138. "foo",
  139. "[header&header-1 ===]");
  140. // Check if single underlining - works
  141. MT("setextH2",
  142. "foo",
  143. "[header&header-2 -]");
  144. // Check if 3+ -'s work
  145. MT("setextH2",
  146. "foo",
  147. "[header&header-2 ---]");
  148. // Single-line blockquote with trailing space
  149. MT("blockquoteSpace",
  150. "[quote&quote-1 > foo]");
  151. // Single-line blockquote
  152. MT("blockquoteNoSpace",
  153. "[quote&quote-1 >foo]");
  154. // No blank line before blockquote
  155. MT("blockquoteNoBlankLine",
  156. "foo",
  157. "[quote&quote-1 > bar]");
  158. // Nested blockquote
  159. MT("blockquoteSpace",
  160. "[quote&quote-1 > foo]",
  161. "[quote&quote-1 >][quote&quote-2 > foo]",
  162. "[quote&quote-1 >][quote&quote-2 >][quote&quote-3 > foo]");
  163. // Single-line blockquote followed by normal paragraph
  164. MT("blockquoteThenParagraph",
  165. "[quote&quote-1 >foo]",
  166. "",
  167. "bar");
  168. // Multi-line blockquote (lazy mode)
  169. MT("multiBlockquoteLazy",
  170. "[quote&quote-1 >foo]",
  171. "[quote&quote-1 bar]");
  172. // Multi-line blockquote followed by normal paragraph (lazy mode)
  173. MT("multiBlockquoteLazyThenParagraph",
  174. "[quote&quote-1 >foo]",
  175. "[quote&quote-1 bar]",
  176. "",
  177. "hello");
  178. // Multi-line blockquote (non-lazy mode)
  179. MT("multiBlockquote",
  180. "[quote&quote-1 >foo]",
  181. "[quote&quote-1 >bar]");
  182. // Multi-line blockquote followed by normal paragraph (non-lazy mode)
  183. MT("multiBlockquoteThenParagraph",
  184. "[quote&quote-1 >foo]",
  185. "[quote&quote-1 >bar]",
  186. "",
  187. "hello");
  188. // Check list types
  189. MT("listAsterisk",
  190. "foo",
  191. "bar",
  192. "",
  193. "[variable-2 * foo]",
  194. "[variable-2 * bar]");
  195. MT("listPlus",
  196. "foo",
  197. "bar",
  198. "",
  199. "[variable-2 + foo]",
  200. "[variable-2 + bar]");
  201. MT("listDash",
  202. "foo",
  203. "bar",
  204. "",
  205. "[variable-2 - foo]",
  206. "[variable-2 - bar]");
  207. MT("listNumber",
  208. "foo",
  209. "bar",
  210. "",
  211. "[variable-2 1. foo]",
  212. "[variable-2 2. bar]");
  213. // Lists require a preceding blank line (per Dingus)
  214. MT("listBogus",
  215. "foo",
  216. "1. bar",
  217. "2. hello");
  218. // List after header
  219. MT("listAfterHeader",
  220. "[header&header-1 # foo]",
  221. "[variable-2 - bar]");
  222. // Formatting in lists (*)
  223. MT("listAsteriskFormatting",
  224. "[variable-2 * ][variable-2&em *foo*][variable-2 bar]",
  225. "[variable-2 * ][variable-2&strong **foo**][variable-2 bar]",
  226. "[variable-2 * ][variable-2&strong **][variable-2&em&strong *foo**][variable-2&em *][variable-2 bar]",
  227. "[variable-2 * ][variable-2&comment `foo`][variable-2 bar]");
  228. // Formatting in lists (+)
  229. MT("listPlusFormatting",
  230. "[variable-2 + ][variable-2&em *foo*][variable-2 bar]",
  231. "[variable-2 + ][variable-2&strong **foo**][variable-2 bar]",
  232. "[variable-2 + ][variable-2&strong **][variable-2&em&strong *foo**][variable-2&em *][variable-2 bar]",
  233. "[variable-2 + ][variable-2&comment `foo`][variable-2 bar]");
  234. // Formatting in lists (-)
  235. MT("listDashFormatting",
  236. "[variable-2 - ][variable-2&em *foo*][variable-2 bar]",
  237. "[variable-2 - ][variable-2&strong **foo**][variable-2 bar]",
  238. "[variable-2 - ][variable-2&strong **][variable-2&em&strong *foo**][variable-2&em *][variable-2 bar]",
  239. "[variable-2 - ][variable-2&comment `foo`][variable-2 bar]");
  240. // Formatting in lists (1.)
  241. MT("listNumberFormatting",
  242. "[variable-2 1. ][variable-2&em *foo*][variable-2 bar]",
  243. "[variable-2 2. ][variable-2&strong **foo**][variable-2 bar]",
  244. "[variable-2 3. ][variable-2&strong **][variable-2&em&strong *foo**][variable-2&em *][variable-2 bar]",
  245. "[variable-2 4. ][variable-2&comment `foo`][variable-2 bar]");
  246. // Paragraph lists
  247. MT("listParagraph",
  248. "[variable-2 * foo]",
  249. "",
  250. "[variable-2 * bar]");
  251. // Multi-paragraph lists
  252. //
  253. // 4 spaces
  254. MT("listMultiParagraph",
  255. "[variable-2 * foo]",
  256. "",
  257. "[variable-2 * bar]",
  258. "",
  259. " [variable-2 hello]");
  260. // 4 spaces, extra blank lines (should still be list, per Dingus)
  261. MT("listMultiParagraphExtra",
  262. "[variable-2 * foo]",
  263. "",
  264. "[variable-2 * bar]",
  265. "",
  266. "",
  267. " [variable-2 hello]");
  268. // 4 spaces, plus 1 space (should still be list, per Dingus)
  269. MT("listMultiParagraphExtraSpace",
  270. "[variable-2 * foo]",
  271. "",
  272. "[variable-2 * bar]",
  273. "",
  274. " [variable-2 hello]",
  275. "",
  276. " [variable-2 world]");
  277. // 1 tab
  278. MT("listTab",
  279. "[variable-2 * foo]",
  280. "",
  281. "[variable-2 * bar]",
  282. "",
  283. "\t[variable-2 hello]");
  284. // No indent
  285. MT("listNoIndent",
  286. "[variable-2 * foo]",
  287. "",
  288. "[variable-2 * bar]",
  289. "",
  290. "hello");
  291. // Blockquote
  292. MT("blockquote",
  293. "[variable-2 * foo]",
  294. "",
  295. "[variable-2 * bar]",
  296. "",
  297. " [variable-2&quote&quote-1 > hello]");
  298. // Code block
  299. MT("blockquoteCode",
  300. "[variable-2 * foo]",
  301. "",
  302. "[variable-2 * bar]",
  303. "",
  304. " [comment > hello]",
  305. "",
  306. " [variable-2 world]");
  307. // Code block followed by text
  308. MT("blockquoteCodeText",
  309. "[variable-2 * foo]",
  310. "",
  311. " [variable-2 bar]",
  312. "",
  313. " [comment hello]",
  314. "",
  315. " [variable-2 world]");
  316. // Nested list
  317. MT("listAsteriskNested",
  318. "[variable-2 * foo]",
  319. "",
  320. " [variable-3 * bar]");
  321. MT("listPlusNested",
  322. "[variable-2 + foo]",
  323. "",
  324. " [variable-3 + bar]");
  325. MT("listDashNested",
  326. "[variable-2 - foo]",
  327. "",
  328. " [variable-3 - bar]");
  329. MT("listNumberNested",
  330. "[variable-2 1. foo]",
  331. "",
  332. " [variable-3 2. bar]");
  333. MT("listMixed",
  334. "[variable-2 * foo]",
  335. "",
  336. " [variable-3 + bar]",
  337. "",
  338. " [keyword - hello]",
  339. "",
  340. " [variable-2 1. world]");
  341. MT("listBlockquote",
  342. "[variable-2 * foo]",
  343. "",
  344. " [variable-3 + bar]",
  345. "",
  346. " [quote&quote-1&variable-3 > hello]");
  347. MT("listCode",
  348. "[variable-2 * foo]",
  349. "",
  350. " [variable-3 + bar]",
  351. "",
  352. " [comment hello]");
  353. // Code with internal indentation
  354. MT("listCodeIndentation",
  355. "[variable-2 * foo]",
  356. "",
  357. " [comment bar]",
  358. " [comment hello]",
  359. " [comment world]",
  360. " [comment foo]",
  361. " [variable-2 bar]");
  362. // List nesting edge cases
  363. MT("listNested",
  364. "[variable-2 * foo]",
  365. "",
  366. " [variable-3 * bar]",
  367. "",
  368. " [variable-2 hello]"
  369. );
  370. MT("listNested",
  371. "[variable-2 * foo]",
  372. "",
  373. " [variable-3 * bar]",
  374. "",
  375. " [variable-3 * foo]"
  376. );
  377. // Code followed by text
  378. MT("listCodeText",
  379. "[variable-2 * foo]",
  380. "",
  381. " [comment bar]",
  382. "",
  383. "hello");
  384. // Following tests directly from official Markdown documentation
  385. // http://daringfireball.net/projects/markdown/syntax#hr
  386. MT("hrSpace",
  387. "[hr * * *]");
  388. MT("hr",
  389. "[hr ***]");
  390. MT("hrLong",
  391. "[hr *****]");
  392. MT("hrSpaceDash",
  393. "[hr - - -]");
  394. MT("hrDashLong",
  395. "[hr ---------------------------------------]");
  396. // Inline link with title
  397. MT("linkTitle",
  398. "[link [[foo]]][string (http://example.com/ \"bar\")] hello");
  399. // Inline link without title
  400. MT("linkNoTitle",
  401. "[link [[foo]]][string (http://example.com/)] bar");
  402. // Inline link with image
  403. MT("linkImage",
  404. "[link [[][tag ![[foo]]][string (http://example.com/)][link ]]][string (http://example.com/)] bar");
  405. // Inline link with Em
  406. MT("linkEm",
  407. "[link [[][link&em *foo*][link ]]][string (http://example.com/)] bar");
  408. // Inline link with Strong
  409. MT("linkStrong",
  410. "[link [[][link&strong **foo**][link ]]][string (http://example.com/)] bar");
  411. // Inline link with EmStrong
  412. MT("linkEmStrong",
  413. "[link [[][link&strong **][link&em&strong *foo**][link&em *][link ]]][string (http://example.com/)] bar");
  414. // Image with title
  415. MT("imageTitle",
  416. "[tag ![[foo]]][string (http://example.com/ \"bar\")] hello");
  417. // Image without title
  418. MT("imageNoTitle",
  419. "[tag ![[foo]]][string (http://example.com/)] bar");
  420. // Image with asterisks
  421. MT("imageAsterisks",
  422. "[tag ![[*foo*]]][string (http://example.com/)] bar");
  423. // Not a link. Should be normal text due to square brackets being used
  424. // regularly in text, especially in quoted material, and no space is allowed
  425. // between square brackets and parentheses (per Dingus).
  426. MT("notALink",
  427. "[[foo]] (bar)");
  428. // Reference-style links
  429. MT("linkReference",
  430. "[link [[foo]]][string [[bar]]] hello");
  431. // Reference-style links with Em
  432. MT("linkReferenceEm",
  433. "[link [[][link&em *foo*][link ]]][string [[bar]]] hello");
  434. // Reference-style links with Strong
  435. MT("linkReferenceStrong",
  436. "[link [[][link&strong **foo**][link ]]][string [[bar]]] hello");
  437. // Reference-style links with EmStrong
  438. MT("linkReferenceEmStrong",
  439. "[link [[][link&strong **][link&em&strong *foo**][link&em *][link ]]][string [[bar]]] hello");
  440. // Reference-style links with optional space separator (per docuentation)
  441. // "You can optionally use a space to separate the sets of brackets"
  442. MT("linkReferenceSpace",
  443. "[link [[foo]]] [string [[bar]]] hello");
  444. // Should only allow a single space ("...use *a* space...")
  445. MT("linkReferenceDoubleSpace",
  446. "[[foo]] [[bar]] hello");
  447. // Reference-style links with implicit link name
  448. MT("linkImplicit",
  449. "[link [[foo]]][string [[]]] hello");
  450. // @todo It would be nice if, at some point, the document was actually
  451. // checked to see if the referenced link exists
  452. // Link label, for reference-style links (taken from documentation)
  453. MT("labelNoTitle",
  454. "[link [[foo]]:] [string http://example.com/]");
  455. MT("labelIndented",
  456. " [link [[foo]]:] [string http://example.com/]");
  457. MT("labelSpaceTitle",
  458. "[link [[foo bar]]:] [string http://example.com/ \"hello\"]");
  459. MT("labelDoubleTitle",
  460. "[link [[foo bar]]:] [string http://example.com/ \"hello\"] \"world\"");
  461. MT("labelTitleDoubleQuotes",
  462. "[link [[foo]]:] [string http://example.com/ \"bar\"]");
  463. MT("labelTitleSingleQuotes",
  464. "[link [[foo]]:] [string http://example.com/ 'bar']");
  465. MT("labelTitleParenthese",
  466. "[link [[foo]]:] [string http://example.com/ (bar)]");
  467. MT("labelTitleInvalid",
  468. "[link [[foo]]:] [string http://example.com/] bar");
  469. MT("labelLinkAngleBrackets",
  470. "[link [[foo]]:] [string <http://example.com/> \"bar\"]");
  471. MT("labelTitleNextDoubleQuotes",
  472. "[link [[foo]]:] [string http://example.com/]",
  473. "[string \"bar\"] hello");
  474. MT("labelTitleNextSingleQuotes",
  475. "[link [[foo]]:] [string http://example.com/]",
  476. "[string 'bar'] hello");
  477. MT("labelTitleNextParenthese",
  478. "[link [[foo]]:] [string http://example.com/]",
  479. "[string (bar)] hello");
  480. MT("labelTitleNextMixed",
  481. "[link [[foo]]:] [string http://example.com/]",
  482. "(bar\" hello");
  483. MT("linkWeb",
  484. "[link <http://example.com/>] foo");
  485. MT("linkWebDouble",
  486. "[link <http://example.com/>] foo [link <http://example.com/>]");
  487. MT("linkEmail",
  488. "[link <user@example.com>] foo");
  489. MT("linkEmailDouble",
  490. "[link <user@example.com>] foo [link <user@example.com>]");
  491. MT("emAsterisk",
  492. "[em *foo*] bar");
  493. MT("emUnderscore",
  494. "[em _foo_] bar");
  495. MT("emInWordAsterisk",
  496. "foo[em *bar*]hello");
  497. MT("emInWordUnderscore",
  498. "foo[em _bar_]hello");
  499. // Per documentation: "...surround an * or _ with spaces, it’ll be
  500. // treated as a literal asterisk or underscore."
  501. MT("emEscapedBySpaceIn",
  502. "foo [em _bar _ hello_] world");
  503. MT("emEscapedBySpaceOut",
  504. "foo _ bar[em _hello_]world");
  505. MT("emEscapedByNewline",
  506. "foo",
  507. "_ bar[em _hello_]world");
  508. // Unclosed emphasis characters
  509. // Instead of simply marking as EM / STRONG, it would be nice to have an
  510. // incomplete flag for EM and STRONG, that is styled slightly different.
  511. MT("emIncompleteAsterisk",
  512. "foo [em *bar]");
  513. MT("emIncompleteUnderscore",
  514. "foo [em _bar]");
  515. MT("strongAsterisk",
  516. "[strong **foo**] bar");
  517. MT("strongUnderscore",
  518. "[strong __foo__] bar");
  519. MT("emStrongAsterisk",
  520. "[em *foo][em&strong **bar*][strong hello**] world");
  521. MT("emStrongUnderscore",
  522. "[em _foo][em&strong __bar_][strong hello__] world");
  523. // "...same character must be used to open and close an emphasis span.""
  524. MT("emStrongMixed",
  525. "[em _foo][em&strong **bar*hello__ world]");
  526. MT("emStrongMixed",
  527. "[em *foo][em&strong __bar_hello** world]");
  528. // These characters should be escaped:
  529. // \ backslash
  530. // ` backtick
  531. // * asterisk
  532. // _ underscore
  533. // {} curly braces
  534. // [] square brackets
  535. // () parentheses
  536. // # hash mark
  537. // + plus sign
  538. // - minus sign (hyphen)
  539. // . dot
  540. // ! exclamation mark
  541. MT("escapeBacktick",
  542. "foo \\`bar\\`");
  543. MT("doubleEscapeBacktick",
  544. "foo \\\\[comment `bar\\\\`]");
  545. MT("escapeAsterisk",
  546. "foo \\*bar\\*");
  547. MT("doubleEscapeAsterisk",
  548. "foo \\\\[em *bar\\\\*]");
  549. MT("escapeUnderscore",
  550. "foo \\_bar\\_");
  551. MT("doubleEscapeUnderscore",
  552. "foo \\\\[em _bar\\\\_]");
  553. MT("escapeHash",
  554. "\\# foo");
  555. MT("doubleEscapeHash",
  556. "\\\\# foo");
  557. MT("escapeNewline",
  558. "\\",
  559. "[em *foo*]");
  560. // Tests to make sure GFM-specific things aren't getting through
  561. MT("taskList",
  562. "[variable-2 * [ ]] bar]");
  563. MT("fencedCodeBlocks",
  564. "[comment ```]",
  565. "foo",
  566. "[comment ```]");
  567. })();