thephpleague / commonmark

Highly-extensible PHP Markdown parser which fully supports the CommonMark and GFM specs.
https://commonmark.thephpleague.com
BSD 3-Clause "New" or "Revised" License
2.75k stars 194 forks source link

Allow CSS level 3 selectors for classes and ids in the attributes extension #1013

Closed xavierlacot closed 4 months ago

xavierlacot commented 9 months ago

The CSS level 3 Syntax, which is a Recommendation since 2018, allows much more characters in id and class selectors than the ones currently supported by the "Attributes" extension:

https://github.com/thephpleague/commonmark/blob/91c24291965bd6d7c46c46a12ba7492f83b1cadf/src/Extension/Attributes/Util/AttributesHelper.php#L26

The formal CSS level 3 selectors grammar is detailed here: https://www.w3.org/TR/selectors-3/#w3cselgrammar

This pull request adds a test to check several valid class and id names that are currently failing to be parsed as valid attribute values by the "Attributes" extension, and it proposes a fix for this issue.