rouge
rouge copied to clipboard
Swift lexer update for syntax highlight for macros and keywords
Hi,
I've reviewed the code of conduct. Here is a summary of the changes.
What is the issue?
- The Rouge syntax highlighter for Swift didn't recognize #expect from Swift Testing framework, treating it as a generic preprocessor instead of a testing assertion. Basically, the rule catches ANY line starting with
#(except for##,#", or#/) and treats the entire line as a preprocessor comment.
Changes
-
Added a
testing_macrosset containingexpectandrequire -
Modified the rule for
#prefixed identifiers to check if they're Swift Testing macros -
Swift Testing macros (
#expect,#require) are now highlighted asName::Builtin -
Other Swift macros (like
#selector) continue to be highlighted asKeyword -
Preprocessor directives (
#if,#else,#endif) are properly handled in the:bolstate
Testing
- Ran the the tests locally, looks alright.