fix(bash): correctly highlight doctags in comments again (#4234) #4239
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Previously, because whitespace needed to be detected as part of the comment, but not highlighted that way, the match was split and only the second part of the match was assigned a scope. However, for reasons I couldn’t figure out, it seems that the presence of multiple
scope
values breaks thecontains
highlighting logic for a mode. (Or something to that effect.)Rather than resolving whatever’s causing that problem, this PR changes the regex to use a lookbehind assertion, thus requiring the whitespace to be there without capturing it as part of the match.
I think this is a breaking change: #3890 says that negative lookbehinds aren’t allowed in Highlight.js until v12 because of Safari support; it seems like the same is true of positive lookbehind, in which case merging this requires a major version bump.
Closes #4234.
Checklist
CHANGES.md
(Full disclosure: this patch was prepared with the assistance of an LLM. However I have prepared this PR description myself, and am confident that the changes are correct.)