Theme Inspinia
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test.js 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: http://codemirror.net/LICENSE
  3. (function() {
  4. var mode = CodeMirror.getMode({tabSize: 4}, "gfm");
  5. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  6. var modeHighlightFormatting = CodeMirror.getMode({tabSize: 4}, {name: "gfm", highlightFormatting: true});
  7. function FT(name) { test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1)); }
  8. FT("codeBackticks",
  9. "[comment&formatting&formatting-code `][comment foo][comment&formatting&formatting-code `]");
  10. FT("doubleBackticks",
  11. "[comment&formatting&formatting-code ``][comment foo ` bar][comment&formatting&formatting-code ``]");
  12. FT("codeBlock",
  13. "[comment&formatting&formatting-code-block ```css]",
  14. "[tag foo]",
  15. "[comment&formatting&formatting-code-block ```]");
  16. FT("taskList",
  17. "[variable-2&formatting&formatting-list&formatting-list-ul - ][meta&formatting&formatting-task [ ]]][variable-2 foo]",
  18. "[variable-2&formatting&formatting-list&formatting-list-ul - ][property&formatting&formatting-task [x]]][variable-2 foo]");
  19. MT("emInWordAsterisk",
  20. "foo[em *bar*]hello");
  21. MT("emInWordUnderscore",
  22. "foo_bar_hello");
  23. MT("emStrongUnderscore",
  24. "[strong __][em&strong _foo__][em _] bar");
  25. MT("fencedCodeBlocks",
  26. "[comment ```]",
  27. "[comment foo]",
  28. "",
  29. "[comment ```]",
  30. "bar");
  31. MT("fencedCodeBlockModeSwitching",
  32. "[comment ```javascript]",
  33. "[variable foo]",
  34. "",
  35. "[comment ```]",
  36. "bar");
  37. MT("taskListAsterisk",
  38. "[variable-2 * []] foo]", // Invalid; must have space or x between []
  39. "[variable-2 * [ ]]bar]", // Invalid; must have space after ]
  40. "[variable-2 * [x]]hello]", // Invalid; must have space after ]
  41. "[variable-2 * ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
  42. " [variable-3 * ][property [x]]][variable-3 foo]"); // Valid; can be nested
  43. MT("taskListPlus",
  44. "[variable-2 + []] foo]", // Invalid; must have space or x between []
  45. "[variable-2 + [ ]]bar]", // Invalid; must have space after ]
  46. "[variable-2 + [x]]hello]", // Invalid; must have space after ]
  47. "[variable-2 + ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
  48. " [variable-3 + ][property [x]]][variable-3 foo]"); // Valid; can be nested
  49. MT("taskListDash",
  50. "[variable-2 - []] foo]", // Invalid; must have space or x between []
  51. "[variable-2 - [ ]]bar]", // Invalid; must have space after ]
  52. "[variable-2 - [x]]hello]", // Invalid; must have space after ]
  53. "[variable-2 - ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
  54. " [variable-3 - ][property [x]]][variable-3 foo]"); // Valid; can be nested
  55. MT("taskListNumber",
  56. "[variable-2 1. []] foo]", // Invalid; must have space or x between []
  57. "[variable-2 2. [ ]]bar]", // Invalid; must have space after ]
  58. "[variable-2 3. [x]]hello]", // Invalid; must have space after ]
  59. "[variable-2 4. ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
  60. " [variable-3 1. ][property [x]]][variable-3 foo]"); // Valid; can be nested
  61. MT("SHA",
  62. "foo [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] bar");
  63. MT("SHAEmphasis",
  64. "[em *foo ][em&link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]");
  65. MT("shortSHA",
  66. "foo [link be6a8cc] bar");
  67. MT("tooShortSHA",
  68. "foo be6a8c bar");
  69. MT("longSHA",
  70. "foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar");
  71. MT("badSHA",
  72. "foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar");
  73. MT("userSHA",
  74. "foo [link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] hello");
  75. MT("userSHAEmphasis",
  76. "[em *foo ][em&link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]");
  77. MT("userProjectSHA",
  78. "foo [link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] world");
  79. MT("userProjectSHAEmphasis",
  80. "[em *foo ][em&link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]");
  81. MT("num",
  82. "foo [link #1] bar");
  83. MT("numEmphasis",
  84. "[em *foo ][em&link #1][em *]");
  85. MT("badNum",
  86. "foo #1bar hello");
  87. MT("userNum",
  88. "foo [link bar#1] hello");
  89. MT("userNumEmphasis",
  90. "[em *foo ][em&link bar#1][em *]");
  91. MT("userProjectNum",
  92. "foo [link bar/hello#1] world");
  93. MT("userProjectNumEmphasis",
  94. "[em *foo ][em&link bar/hello#1][em *]");
  95. MT("vanillaLink",
  96. "foo [link http://www.example.com/] bar");
  97. MT("vanillaLinkPunctuation",
  98. "foo [link http://www.example.com/]. bar");
  99. MT("vanillaLinkExtension",
  100. "foo [link http://www.example.com/index.html] bar");
  101. MT("vanillaLinkEmphasis",
  102. "foo [em *][em&link http://www.example.com/index.html][em *] bar");
  103. MT("notALink",
  104. "[comment ```css]",
  105. "[tag foo] {[property color]:[keyword black];}",
  106. "[comment ```][link http://www.example.com/]");
  107. MT("notALink",
  108. "[comment ``foo `bar` http://www.example.com/``] hello");
  109. MT("notALink",
  110. "[comment `foo]",
  111. "[link http://www.example.com/]",
  112. "[comment `foo]",
  113. "",
  114. "[link http://www.example.com/]");
  115. MT("headerCodeBlockGithub",
  116. "[header&header-1 # heading]",
  117. "",
  118. "[comment ```]",
  119. "[comment code]",
  120. "[comment ```]",
  121. "",
  122. "Commit: [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2]",
  123. "Issue: [link #1]",
  124. "Link: [link http://www.example.com/]");
  125. })();