Skip to content

Commit

Permalink
fix(css) variable '_' detection #3823 (#3863)
Browse files Browse the repository at this point in the history
  • Loading branch information
akhtarmdsaad authored Oct 8, 2023
1 parent 2708bf9 commit a1a1235
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Core Grammars:
- fix(swift) `warn_unqualified_access` is an attribute [Bradley Mackey][]
- enh(swift) macro attributes are highlighted as keywords [Bradley Mackey][]
- enh(stan) updated for version 2.33 (#3859) [Brian Ward][]
- fix(css) added '_' css variable detection [Md Saad Akhtar][]

Dev tool:

Expand All @@ -64,7 +65,7 @@ Dev tool:
[Nicholas Thompson]: https://github.com/NAThompson
[Yasith Deelaka]: https://github.com/YasithD
[Brian Ward]: https://github.com/WardBrian

[Md Saad Akhtar]: https://github.com/akhtarmdsaad

## Version 11.8.0

Expand Down
2 changes: 1 addition & 1 deletion src/languages/lib/css-shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const MODES = (hljs) => {
},
CSS_VARIABLE: {
className: "attr",
begin: /--[A-Za-z][A-Za-z0-9_-]*/
begin: /--[A-Za-z_][A-Za-z0-9_-]*/
}
};
};
Expand Down
5 changes: 5 additions & 0 deletions test/markup/css/variables.expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@
<span class="hljs-attr">--textBlue</span>: blue;
<span class="hljs-attribute">color</span>: <span class="hljs-built_in">var</span>(--textBlue);
}

<span class="hljs-selector-tag">body</span> {
<span class="hljs-attr">--_margin-top</span>: <span class="hljs-number">1rem</span>;
<span class="hljs-attribute">margin-top</span>: <span class="hljs-built_in">var</span>(--_margin-top);
}
6 changes: 6 additions & 0 deletions test/markup/css/variables.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ body {
--textBlue: blue;
color: var(--textBlue);
}

body {
--_margin-top: 1rem;
margin-top: var(--_margin-top);
}

0 comments on commit a1a1235

Please sign in to comment.