highlight.js icon indicating copy to clipboard operation
highlight.js copied to clipboard

enh(nsis) improve highlighter rules and tests

Open idleberg opened this issue 2 years ago • 1 comments

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

idleberg avatar Jul 16 '23 20:07 idleberg

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_$%!#]*',
    },

joshgoebel avatar Jul 18 '23 02:07 joshgoebel

Closing for inactivity, but we can reopen anytime you have time to revisit this work.

joshgoebel avatar Mar 21 '24 01:03 joshgoebel