fix(markdown) Ignore mid_word underscores#4342
Conversation
Build Size ReportChanges to minified artifacts in 4 files changedTotal change +22 B View Changes
|
| begin: /_(?![_\s])/, | ||
| end: /_/, | ||
| begin: /(?<![a-zA-Z0-9])_(?![_\s])/, | ||
| end: /_(?![a-zA-Z0-9])/, |
There was a problem hiding this comment.
This will have to sit until v12 unless you know how to do this without negative look-behind... this would be a breaking change for older versions of Safari that v11 still supports.
There was a problem hiding this comment.
Thanks for taking a look @joshgoebel. Is there any guess when there might be a v12? Is it months, years, maybe never?
Claude came up with a more complex version that doesn't have any negative lookbehind. If this seems reasonable, I can move it over to this PR:
main...danvk:highlight.js:markdown-midword-underscore-no-lookbehind
There was a problem hiding this comment.
Hard to say, I would have thought a year ago but then I got busy with life.
I guess if we're never going to need to match on that last character for another mode then it could be gobbled up by the "guard" here, yes... When you pull that over please also leave your negative look-behind in place, just comment it out and add a short comment that it's for v12+.
Resolves #4279
Changes
This changes the markdown rule to ignore mid-word
_characters. This brings highlight.js in line with GFM (GitHub-Flavored Markdown). There's no official standard for Markdown and different renderers vary in how they handlemid_wordunderscores. Not italicizing them is the more conservative behavior, and avoids the common situation where a large fraction of your Markdown file turns italic with highlight.js when it does not with GitHub.Checklist
CHANGES.md