trishume / syntect

Rust library for syntax highlighting using Sublime Text syntax definitions.
https://docs.rs/syntect
MIT License
1.89k stars 132 forks source link

Fix #308 by escaping CSS class names #539

Open charlyisidore opened 5 months ago

charlyisidore commented 5 months ago

This pull request is a fix for the issue #308 .

It modifies css_for_theme_with_class_style() to automatically escape special characters in CSS class names according to the CSS specification.

For example, .123 is replaced by .\31 23, and .c++ is replaced by .c\2b \2b.

Class names are escaped using the added function escape_css_identifier().

This PR also adds two tests: one to check the result of escape_css_identifier(), and one to check if the generated CSS for the Solarized (dark) theme is properly escaped.

If you have any suggestion or question, please don't hesitate to let me know.

Many thanks

keith-hall commented 2 months ago

I don't remember why the build failed now and the logs got deleted from being too old, it would be nice to get this to pass CI and merged...