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.

122 lines
5.0 KiB

7 months ago
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://codemirror.net/5/LICENSE
  3. (function() {
  4. var mode = CodeMirror.getMode({indentUnit: 2}, "sass");
  5. // Since Sass has an indent-based syntax, is almost impossible to test correctly the indentation in all cases.
  6. // So disable it for tests.
  7. mode.indent = undefined;
  8. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  9. MT("comment",
  10. "[comment // this is a comment]",
  11. "[comment also this is a comment]")
  12. MT("comment_multiline",
  13. "[comment /* this is a comment]",
  14. "[comment also this is a comment]")
  15. MT("variable",
  16. "[variable-2 $page-width][operator :] [number 800][unit px]")
  17. MT("global_attributes",
  18. "[tag body]",
  19. " [property font][operator :]",
  20. " [property family][operator :] [atom sans-serif]",
  21. " [property size][operator :] [number 30][unit em]",
  22. " [property weight][operator :] [atom bold]")
  23. MT("scoped_styles",
  24. "[builtin #contents]",
  25. " [property width][operator :] [variable-2 $page-width]",
  26. " [builtin #sidebar]",
  27. " [property float][operator :] [atom right]",
  28. " [property width][operator :] [variable-2 $sidebar-width]",
  29. " [builtin #main]",
  30. " [property width][operator :] [variable-2 $page-width] [operator -] [variable-2 $sidebar-width]",
  31. " [property background][operator :] [variable-2 $primary-color]",
  32. " [tag h2]",
  33. " [property color][operator :] [keyword blue]")
  34. // Sass allows to write the colon as first char instead of a "separator".
  35. // :color red
  36. // Not supported
  37. // MT("property_syntax",
  38. // "[qualifier .foo]",
  39. // " [operator :][property color] [keyword red]")
  40. MT("import",
  41. "[def @import] [string \"sass/variables\"]",
  42. // Probably it should parsed as above: as a string even without the " or '
  43. // "[def @import] [string sass/baz]"
  44. "[def @import] [tag sass][operator /][tag baz]")
  45. MT("def",
  46. "[def @if] [variable-2 $foo] [def @else]")
  47. MT("tag_on_more_lines",
  48. "[tag td],",
  49. "[tag th]",
  50. " [property font-family][operator :] [string \"Arial\"], [atom serif]")
  51. MT("important",
  52. "[qualifier .foo]",
  53. " [property text-decoration][operator :] [atom none] [keyword !important]",
  54. "[tag h1]",
  55. " [property font-size][operator :] [number 2.5][unit em]")
  56. MT("selector",
  57. // SCSS doesn't highlight the :
  58. // "[tag h1]:[variable-3 before],",
  59. // "[tag h2]:[variable-3 before]",
  60. "[tag h1][variable-3 :before],",
  61. "[tag h2][variable-3 :before]",
  62. " [property content][operator :] [string \"::\"]")
  63. MT("definition_mixin_equal",
  64. "[variable-2 $defined-bs-type][operator :] [atom border-box] [keyword !default]",
  65. "[meta =bs][operator (][variable-2 $bs-type][operator :] [variable-2 $defined-bs-type][operator )]",
  66. " [meta -webkit-][property box-sizing][operator :] [variable-2 $bs-type]",
  67. " [property box-sizing][operator :] [variable-2 $bs-type]")
  68. MT("definition_mixin_with_space",
  69. "[variable-2 $defined-bs-type][operator :] [atom border-box] [keyword !default]",
  70. "[def @mixin] [tag bs][operator (][variable-2 $bs-type][operator :] [variable-2 $defined-bs-type][operator )] ",
  71. " [meta -moz-][property box-sizing][operator :] [variable-2 $bs-type]",
  72. " [property box-sizing][operator :] [variable-2 $bs-type]")
  73. MT("numbers_start_dot_include_plus",
  74. // The % is not highlighted correctly
  75. // "[meta =button-links][operator (][variable-2 $button-base][operator :] [atom darken][operator (][variable-2 $color11], [number 10][unit %][operator )][operator )]",
  76. "[meta =button-links][operator (][variable-2 $button-base][operator :] [atom darken][operator (][variable-2 $color11], [number 10][operator %))]",
  77. " [property padding][operator :] [number .3][unit em] [number .6][unit em]",
  78. " [variable-3 +border-radius][operator (][number 8][unit px][operator )]",
  79. " [property background-color][operator :] [variable-2 $button-base]")
  80. MT("include",
  81. "[qualifier .bar]",
  82. " [def @include] [tag border-radius][operator (][number 8][unit px][operator )]")
  83. MT("reference_parent",
  84. "[qualifier .col]",
  85. " [property clear][operator :] [atom both]",
  86. // SCSS doesn't highlight the :
  87. // " &:[variable-3 after]",
  88. " &[variable-3 :after]",
  89. " [property content][operator :] [string '']",
  90. " [property clear][operator :] [atom both]")
  91. MT("reference_parent_with_spaces",
  92. "[tag section]",
  93. " [property border-left][operator :] [number 20][unit px] [atom transparent] [atom solid] ",
  94. " &[qualifier .section3]",
  95. " [qualifier .title]",
  96. " [property color][operator :] [keyword white] ",
  97. " [qualifier .vermas]",
  98. " [property display][operator :] [atom none]")
  99. MT("font_face",
  100. "[def @font-face]",
  101. " [property font-family][operator :] [string 'icomoon']",
  102. " [property src][operator :] [atom url][operator (][string fonts/icomoon.ttf][operator )]")
  103. })();