1
0

test.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. (function() {
  2. var mode = CodeMirror.getMode({tabSize: 4}, "gfm");
  3. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  4. MT("emInWordAsterisk",
  5. "foo[em *bar*]hello");
  6. MT("emInWordUnderscore",
  7. "foo_bar_hello");
  8. MT("emStrongUnderscore",
  9. "[strong __][em&strong _foo__][em _] bar");
  10. MT("fencedCodeBlocks",
  11. "[comment ```]",
  12. "[comment foo]",
  13. "",
  14. "[comment ```]",
  15. "bar");
  16. MT("fencedCodeBlockModeSwitching",
  17. "[comment ```javascript]",
  18. "[variable foo]",
  19. "",
  20. "[comment ```]",
  21. "bar");
  22. MT("taskListAsterisk",
  23. "[variable-2 * []] foo]", // Invalid; must have space or x between []
  24. "[variable-2 * [ ]]bar]", // Invalid; must have space after ]
  25. "[variable-2 * [x]]hello]", // Invalid; must have space after ]
  26. "[variable-2 * ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
  27. " [variable-3 * ][property [x]]][variable-3 foo]"); // Valid; can be nested
  28. MT("taskListPlus",
  29. "[variable-2 + []] foo]", // Invalid; must have space or x between []
  30. "[variable-2 + [ ]]bar]", // Invalid; must have space after ]
  31. "[variable-2 + [x]]hello]", // Invalid; must have space after ]
  32. "[variable-2 + ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
  33. " [variable-3 + ][property [x]]][variable-3 foo]"); // Valid; can be nested
  34. MT("taskListDash",
  35. "[variable-2 - []] foo]", // Invalid; must have space or x between []
  36. "[variable-2 - [ ]]bar]", // Invalid; must have space after ]
  37. "[variable-2 - [x]]hello]", // Invalid; must have space after ]
  38. "[variable-2 - ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
  39. " [variable-3 - ][property [x]]][variable-3 foo]"); // Valid; can be nested
  40. MT("taskListNumber",
  41. "[variable-2 1. []] foo]", // Invalid; must have space or x between []
  42. "[variable-2 2. [ ]]bar]", // Invalid; must have space after ]
  43. "[variable-2 3. [x]]hello]", // Invalid; must have space after ]
  44. "[variable-2 4. ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
  45. " [variable-3 1. ][property [x]]][variable-3 foo]"); // Valid; can be nested
  46. MT("SHA",
  47. "foo [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] bar");
  48. MT("shortSHA",
  49. "foo [link be6a8cc] bar");
  50. MT("tooShortSHA",
  51. "foo be6a8c bar");
  52. MT("longSHA",
  53. "foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar");
  54. MT("badSHA",
  55. "foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar");
  56. MT("userSHA",
  57. "foo [link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] hello");
  58. MT("userProjectSHA",
  59. "foo [link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] world");
  60. MT("num",
  61. "foo [link #1] bar");
  62. MT("badNum",
  63. "foo #1bar hello");
  64. MT("userNum",
  65. "foo [link bar#1] hello");
  66. MT("userProjectNum",
  67. "foo [link bar/hello#1] world");
  68. MT("vanillaLink",
  69. "foo [link http://www.example.com/] bar");
  70. MT("vanillaLinkPunctuation",
  71. "foo [link http://www.example.com/]. bar");
  72. MT("vanillaLinkExtension",
  73. "foo [link http://www.example.com/index.html] bar");
  74. MT("notALink",
  75. "[comment ```css]",
  76. "[tag foo] {[property color][operator :][keyword black];}",
  77. "[comment ```][link http://www.example.com/]");
  78. MT("notALink",
  79. "[comment ``foo `bar` http://www.example.com/``] hello");
  80. MT("notALink",
  81. "[comment `foo]",
  82. "[link http://www.example.com/]",
  83. "[comment `foo]",
  84. "",
  85. "[link http://www.example.com/]");
  86. })();