Minor issue when highlighting some PHP attributes
Closed this issue · 2 comments
The PHP attribute highlight feature that @wouterj implemented in #173 works really well. However, I found an edge case. See:
https://symfony.com/doc/current/reference/constraints/AtLeastOneOf.html#basic-usage
The <span> is applied to the entire PHP attribute, so everything is highlighted as an attribute in this case even if statements like new Assert\Regex('/#/') should be highlighted differently.
In any case, this is very rarely used in Symfony Docs, so it's fine to keep this edge case unfixed if the possible solution is very complex or breaks other things. Thanks!
This is expected. Highlight js/PHP works using scopes, so the whole #[...] part is in the "attribute" scope.
Let me test if this is indeed how this works in the latest highlight.js as well. Maybe I've removed too much from their syntax definition (the attribute part was really big and complex and I hoped to take a workable shortcut 🤭)
Hmm, highlight.js indeed does not work like this. I need to dig deeper into how this works