Skip to content

Commit 719a912

Browse files
nina-pymarijnh
authored andcommitted
Fixes #6402. Adds option to turn off highlighting of non-standard CSS properties
1 parent 8bc57f7 commit 719a912

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Diff for: mode/css/css.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
2929
valueKeywords = parserConfig.valueKeywords || {},
3030
allowNested = parserConfig.allowNested,
3131
lineComment = parserConfig.lineComment,
32-
supportsAtComponent = parserConfig.supportsAtComponent === true;
32+
supportsAtComponent = parserConfig.supportsAtComponent === true,
33+
highlightNonStandardPropertyKeywords = config.highlightNonStandardPropertyKeywords !== false;
3334

3435
var type, override;
3536
function ret(style, tp) { type = tp; return style; }
@@ -197,7 +198,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
197198
override = "property";
198199
return "maybeprop";
199200
} else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
200-
override = "string-2";
201+
override = highlightNonStandardPropertyKeywords ? "string-2" : "property";
201202
return "maybeprop";
202203
} else if (allowNested) {
203204
override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag";
@@ -291,7 +292,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
291292
else if (propertyKeywords.hasOwnProperty(word))
292293
override = "property";
293294
else if (nonStandardPropertyKeywords.hasOwnProperty(word))
294-
override = "string-2";
295+
override = highlightNonStandardPropertyKeywords ? "string-2" : "property";
295296
else if (valueKeywords.hasOwnProperty(word))
296297
override = "atom";
297298
else if (colorKeywords.hasOwnProperty(word))

Diff for: mode/css/index.html

+6
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ <h2>CSS mode</h2>
6868
});
6969
</script>
7070

71+
<p>CSS mode supports this option:</p>
72+
<d1>
73+
<dt><code><strong>highlightNonStandardPropertyKeywords</strong>: boolean</code></dt>
74+
<dd>Whether to highlight non-standard CSS property keywords such as <code>margin-inline</code> or <code>zoom</code> (default: <code>true</code>).</dd>
75+
</d1>
76+
7177
<p><strong>MIME types defined:</strong> <code>text/css</code>, <code>text/x-scss</code> (<a href="scss.html">demo</a>), <code>text/x-less</code> (<a href="less.html">demo</a>).</p>
7278

7379
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#css_*">normal</a>, <a href="../../test/index.html#verbose,css_*">verbose</a>.</p>

0 commit comments

Comments
 (0)