Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed css escape chars #4104

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

fixed css escape chars #4104

wants to merge 7 commits into from

Conversation

Dxuian
Copy link
Contributor

@Dxuian Dxuian commented Aug 30, 2024

Resolves #3965
(fixed the branch issue)
before
image

after
image

Checklist

  • Added markup tests, or they don't apply here because...
  • Updated the changelog at CHANGES.md

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change +68 B

View Changes
file base pr diff
es/core.min.js 8.18 KB 8.18 KB +1 B
es/highlight.min.js 8.18 KB 8.18 KB +1 B
es/languages/css.min.js 4.34 KB 4.38 KB +32 B
highlight.min.js 8.22 KB 8.22 KB +2 B
languages/css.min.js 4.35 KB 4.38 KB +32 B

Copy link

github-actions bot commented Sep 4, 2024

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change +56 B

View Changes
file base pr diff
es/core.min.js 8.18 KB 8.18 KB -3 B
es/highlight.min.js 8.18 KB 8.18 KB -3 B
es/languages/css.min.js 4.34 KB 4.38 KB +32 B
highlight.min.js 8.22 KB 8.22 KB -2 B
languages/css.min.js 4.35 KB 4.38 KB +32 B

Copy link

github-actions bot commented Sep 4, 2024

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change +67 B

View Changes
file base pr diff
es/core.min.js 8.18 KB 8.18 KB +1 B
es/highlight.min.js 8.18 KB 8.18 KB +1 B
es/languages/css.min.js 4.34 KB 4.38 KB +32 B
highlight.min.js 8.22 KB 8.22 KB +1 B
languages/css.min.js 4.35 KB 4.38 KB +32 B

@Dxuian
Copy link
Contributor Author

Dxuian commented Sep 9, 2024

@joshgoebel any input ?

@@ -14,7 +14,7 @@ export default function(hljs) {
const VENDOR_PREFIX = { begin: /-(webkit|moz|ms|o)-(?=[a-z])/ };
const AT_MODIFIERS = "and or not only";
const AT_PROPERTY_RE = /@-?\w[\w]*(-\w+)*/; // @-webkit-keyframes
const IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
const IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*(\\\\:[a-zA-Z0-9_-]+)*';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is :: escaping supported? Or escaping any other chars? Feels like this is just handling this one edge case vs the concept of escaping in general - are there other uses?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ive managed to generalize to include other special chars in the new commit pls review

src/languages/css.js Outdated Show resolved Hide resolved
Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change +130 B

View Changes
file base pr diff
es/core.min.js 8.18 KB 8.18 KB +1 B
es/highlight.min.js 8.18 KB 8.18 KB +1 B
es/languages/css.min.js 4.34 KB 4.41 KB +63 B
highlight.min.js 8.22 KB 8.22 KB +2 B
languages/css.min.js 4.35 KB 4.41 KB +63 B

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

3 files changed

Total change +113 B

View Changes
file base pr diff
es/languages/css.min.js 4.34 KB 4.4 KB +56 B
highlight.min.js 8.22 KB 8.22 KB +1 B
languages/css.min.js 4.35 KB 4.41 KB +56 B

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

2 files changed

Total change +112 B

View Changes
file base pr diff
es/languages/css.min.js 4.34 KB 4.4 KB +56 B
languages/css.min.js 4.35 KB 4.41 KB +56 B

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change +75 B

View Changes
file base pr diff
es/core.min.js 8.18 KB 8.18 KB -1 B
es/highlight.min.js 8.18 KB 8.18 KB -1 B
es/languages/css.min.js 4.34 KB 4.38 KB +38 B
highlight.min.js 8.22 KB 8.22 KB +1 B
languages/css.min.js 4.35 KB 4.39 KB +38 B

@@ -13,8 +13,9 @@ export default function(hljs) {
const modes = css.MODES(hljs);
const VENDOR_PREFIX = { begin: /-(webkit|moz|ms|o)-(?=[a-z])/ };
const AT_MODIFIERS = "and or not only";
const AT_PROPERTY_RE = /@-?\w[\w]*(-\w+)*/; // @-webkit-keyframes
const IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
const AT_PROPERTY_RE = /@-?\b\w[\w-]*\b/; // @-webkit-keyframes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the changes here trying to do?

@Dxuian
Copy link
Contributor Author

Dxuian commented Oct 13, 2024

@joshgoebel ?

@joshgoebel
Copy link
Member

Sorry for the delay. While coming back to this I just remembered that we support many CSS-like grammars - and many of those allow plain old CSS as well as their other syntactic improvements.

SO... to accept a css improvement you would also need to support:

  • less
  • stylus
  • scss

There is a script to help with this.

  • You'd first need to add a small representative sample set of escapes to markup/css/css_consistency.txt...
    • with a paired result file...
  • then use the tools/css script -
    • which will copy the consistency test (as-is) into the less, stylus, and scss folders.

After that you need to work with the less, stylus, and scss grammars to get the markup tests passing - ie their on CSS output must exactly match the output of the CSS grammar.

@joshgoebel
Copy link
Member

Also perhaps look at the css_shared.js file, which might be useful for shared regex, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(css) Escaped special character in selector class name breaks highlighting
2 participants