comparison .cms/lib/codemirror/mode/sass/test.js @ 0:78edf6b517a0 draft

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