highlight.js
highlight.js copied to clipboard
enh(nsis) improve highlighter rules and tests
I have identified several highlighting issues and reported them https://github.com/highlightjs/highlight.js/issues/3821. In my memory, these inconsistencies did not exist in earlier versions, but I could be wrong.
This PR adds some tests to identify the problems Obviously, the highlighting rules need to be updated before a merge, so I consider this PR work in progress.
Specifically, I tried adding block-keywords such as !macro / !macroend to the beginKeywords block, but this did not solve the problem. Could the exclamation mark, as a non-word character cause this problem? Also, defining !macroend before the !macro keyword did not have an effect. I'm looking for some direction on how to tackle these issues!
Changes
- ✅ add test for macro definitions
- ✅ add test for runtime condition
- ✅ fix expected markup for !ifdef keyword
- ✅ fix issues caused by manual editing
- ✅ remove unused import
Todo
- identify and write missing test cases
- fix specific highlighter issues
Checklist
- [x] Added markup tests, or they don't apply here because...
- [ ] Updated the changelog at
CHANGES.md
Could the exclamation mark, as a non-word character cause this problem?
Yes, if using keywords you need to redefine the keyword pattern, see keywords.$pattern in the docs (or source). Such as:
keywords: {
$pattern: '[a-zA-Z][a-zA-Z0-9_$%!#]*',
},
Closing for inactivity, but we can reopen anytime you have time to revisit this work.