1
0

test.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: http://codemirror.net/LICENSE
  3. // Slim Highlighting for CodeMirror copyright (c) HicknHack Software Gmbh
  4. (function() {
  5. var mode = CodeMirror.getMode({tabSize: 4, indentUnit: 2}, "slim");
  6. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  7. // Requires at least one media query
  8. MT("elementName",
  9. "[tag h1] Hey There");
  10. MT("oneElementPerLine",
  11. "[tag h1] Hey There .h2");
  12. MT("idShortcut",
  13. "[attribute&def #test] Hey There");
  14. MT("tagWithIdShortcuts",
  15. "[tag h1][attribute&def #test] Hey There");
  16. MT("classShortcut",
  17. "[attribute&qualifier .hello] Hey There");
  18. MT("tagWithIdAndClassShortcuts",
  19. "[tag h1][attribute&def #test][attribute&qualifier .hello] Hey There");
  20. MT("docType",
  21. "[keyword doctype] xml");
  22. MT("comment",
  23. "[comment / Hello WORLD]");
  24. MT("notComment",
  25. "[tag h1] This is not a / comment ");
  26. MT("attributes",
  27. "[tag a]([attribute title]=[string \"test\"]) [attribute href]=[string \"link\"]}");
  28. MT("multiLineAttributes",
  29. "[tag a]([attribute title]=[string \"test\"]",
  30. " ) [attribute href]=[string \"link\"]}");
  31. MT("htmlCode",
  32. "[tag&bracket <][tag h1][tag&bracket >]Title[tag&bracket </][tag h1][tag&bracket >]");
  33. MT("rubyBlock",
  34. "[operator&special =][variable-2 @item]");
  35. MT("selectorRubyBlock",
  36. "[tag a][attribute&qualifier .test][operator&special =] [variable-2 @item]");
  37. MT("nestedRubyBlock",
  38. "[tag a]",
  39. " [operator&special =][variable puts] [string \"test\"]");
  40. MT("multilinePlaintext",
  41. "[tag p]",
  42. " | Hello,",
  43. " World");
  44. MT("multilineRuby",
  45. "[tag p]",
  46. " [comment /# this is a comment]",
  47. " [comment and this is a comment too]",
  48. " | Date/Time",
  49. " [operator&special -] [variable now] [operator =] [tag DateTime][operator .][property now]",
  50. " [tag strong][operator&special =] [variable now]",
  51. " [operator&special -] [keyword if] [variable now] [operator >] [tag DateTime][operator .][property parse]([string \"December 31, 2006\"])",
  52. " [operator&special =][string \"Happy\"]",
  53. " [operator&special =][string \"Belated\"]",
  54. " [operator&special =][string \"Birthday\"]");
  55. MT("multilineComment",
  56. "[comment /]",
  57. " [comment Multiline]",
  58. " [comment Comment]");
  59. MT("hamlAfterRubyTag",
  60. "[attribute&qualifier .block]",
  61. " [tag strong][operator&special =] [variable now]",
  62. " [attribute&qualifier .test]",
  63. " [operator&special =][variable now]",
  64. " [attribute&qualifier .right]");
  65. MT("stretchedRuby",
  66. "[operator&special =] [variable puts] [string \"Hello\"],",
  67. " [string \"World\"]");
  68. MT("interpolationInHashAttribute",
  69. "[tag div]{[attribute id] = [string \"]#{[variable test]}[string _]#{[variable ting]}[string \"]} test");
  70. MT("interpolationInHTMLAttribute",
  71. "[tag div]([attribute title]=[string \"]#{[variable test]}[string _]#{[variable ting]()}[string \"]) Test");
  72. })();