test.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://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) {
  7. test.mode(name, mode, Array.prototype.slice.call(arguments, 1))
  8. }
  9. // Requires at least one media query
  10. MT('elementName', '[tag h1] Hey There')
  11. MT('oneElementPerLine', '[tag h1] Hey There .h2')
  12. MT('idShortcut', '[attribute&def #test] Hey There')
  13. MT('tagWithIdShortcuts', '[tag h1][attribute&def #test] Hey There')
  14. MT('classShortcut', '[attribute&qualifier .hello] Hey There')
  15. MT('tagWithIdAndClassShortcuts', '[tag h1][attribute&def #test][attribute&qualifier .hello] Hey There')
  16. MT('docType', '[keyword doctype] xml')
  17. MT('comment', '[comment / Hello WORLD]')
  18. MT('notComment', '[tag h1] This is not a / comment ')
  19. MT('attributes', '[tag a]([attribute title]=[string "test"]) [attribute href]=[string "link"]}')
  20. MT('multiLineAttributes', '[tag a]([attribute title]=[string "test"]', ' ) [attribute href]=[string "link"]}')
  21. MT('htmlCode', '[tag&bracket <][tag h1][tag&bracket >]Title[tag&bracket </][tag h1][tag&bracket >]')
  22. MT('rubyBlock', '[operator&special =][variable-2 @item]')
  23. MT('selectorRubyBlock', '[tag a][attribute&qualifier .test][operator&special =] [variable-2 @item]')
  24. MT('nestedRubyBlock', '[tag a]', ' [operator&special =][variable puts] [string "test"]')
  25. MT('multilinePlaintext', '[tag p]', ' | Hello,', ' World')
  26. MT(
  27. 'multilineRuby',
  28. '[tag p]',
  29. ' [comment /# this is a comment]',
  30. ' [comment and this is a comment too]',
  31. ' | Date/Time',
  32. ' [operator&special -] [variable now] [operator =] [tag DateTime][operator .][property now]',
  33. ' [tag strong][operator&special =] [variable now]',
  34. ' [operator&special -] [keyword if] [variable now] [operator >] [tag DateTime][operator .][property parse]([string "December 31, 2006"])',
  35. ' [operator&special =][string "Happy"]',
  36. ' [operator&special =][string "Belated"]',
  37. ' [operator&special =][string "Birthday"]'
  38. )
  39. MT('multilineComment', '[comment /]', ' [comment Multiline]', ' [comment Comment]')
  40. MT(
  41. 'hamlAfterRubyTag',
  42. '[attribute&qualifier .block]',
  43. ' [tag strong][operator&special =] [variable now]',
  44. ' [attribute&qualifier .test]',
  45. ' [operator&special =][variable now]',
  46. ' [attribute&qualifier .right]'
  47. )
  48. MT('stretchedRuby', '[operator&special =] [variable puts] [string "Hello"],', ' [string "World"]')
  49. MT('interpolationInHashAttribute', '[tag div]{[attribute id] = [string "]#{[variable test]}[string _]#{[variable ting]}[string "]} test')
  50. MT('interpolationInHTMLAttribute', '[tag div]([attribute title]=[string "]#{[variable test]}[string _]#{[variable ting]()}[string "]) Test')
  51. })()