Skip to content

Commit

Permalink
Fixes #6402. Adds option to turn off highlighting of non-standard CSS…
Browse files Browse the repository at this point in the history
… properties
  • Loading branch information
nina-py authored and marijnh committed Oct 5, 2020
1 parent 8bc57f7 commit 719a912
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mode/css/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
valueKeywords = parserConfig.valueKeywords || {},
allowNested = parserConfig.allowNested,
lineComment = parserConfig.lineComment,
supportsAtComponent = parserConfig.supportsAtComponent === true;
supportsAtComponent = parserConfig.supportsAtComponent === true,
highlightNonStandardPropertyKeywords = config.highlightNonStandardPropertyKeywords !== false;

var type, override;
function ret(style, tp) { type = tp; return style; }
Expand Down Expand Up @@ -197,7 +198,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
override = "property";
return "maybeprop";
} else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
override = "string-2";
override = highlightNonStandardPropertyKeywords ? "string-2" : "property";
return "maybeprop";
} else if (allowNested) {
override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag";
Expand Down Expand Up @@ -291,7 +292,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
else if (propertyKeywords.hasOwnProperty(word))
override = "property";
else if (nonStandardPropertyKeywords.hasOwnProperty(word))
override = "string-2";
override = highlightNonStandardPropertyKeywords ? "string-2" : "property";
else if (valueKeywords.hasOwnProperty(word))
override = "atom";
else if (colorKeywords.hasOwnProperty(word))
Expand Down
6 changes: 6 additions & 0 deletions mode/css/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ <h2>CSS mode</h2>
});
</script>

<p>CSS mode supports this option:</p>
<d1>
<dt><code><strong>highlightNonStandardPropertyKeywords</strong>: boolean</code></dt>
<dd>Whether to highlight non-standard CSS property keywords such as <code>margin-inline</code> or <code>zoom</code> (default: <code>true</code>).</dd>
</d1>

<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>

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

0 comments on commit 719a912

Please sign in to comment.