From b42703ef5cb001baccbd552aa708e20e217d652d Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Tue, 11 Nov 2025 09:51:48 -0500 Subject: [PATCH 1/2] fix(markdown) Ignore mid_word underscores --- src/languages/markdown.js | 4 ++-- test/markup/markdown/bold_italics.expect.txt | 3 +++ test/markup/markdown/bold_italics.txt | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/languages/markdown.js b/src/languages/markdown.js index 3d73d062e9..5a08a3ff72 100644 --- a/src/languages/markdown.js +++ b/src/languages/markdown.js @@ -156,8 +156,8 @@ export default function(hljs) { end: /\*/ }, { - begin: /_(?![_\s])/, - end: /_/, + begin: /(?> * One (this point is italic) > * Two > * Three + +No italics mid_word underscores. +But italics for _full_word_ with underscores. diff --git a/test/markup/markdown/bold_italics.txt b/test/markup/markdown/bold_italics.txt index c85202e554..fa44e30c83 100644 --- a/test/markup/markdown/bold_italics.txt +++ b/test/markup/markdown/bold_italics.txt @@ -31,3 +31,6 @@ _ not italic_ > * One (this point is italic) > * Two > * Three + +No italics mid_word underscores. +But italics for _full_word_ with underscores. From 868e6cd100c6fe6139c1a3b52c301d7738dd8530 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Tue, 11 Nov 2025 10:12:17 -0500 Subject: [PATCH 2/2] add note to CHANGES.md --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index b1413c29a5..fbc16da121 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -26,6 +26,7 @@ Core Grammars: - enh(json) add json5 support [Kerry Shetline][] - fix(css) `unicode-range` parsing, issue #4253 [Kerry Shetline][] - fix(csharp) Support digit separators [te-ing][] +- fix(markdown) Ignore mid_word underscores, issue #4279 [Dan Vanderkam] Documentation: @@ -55,6 +56,7 @@ CONTRIBUTORS [te-ing]: https://github.com/te-ing [Anthony Martin]: https://github.com/anthony-c-martin [NriotHrreion]: https://github.com/NriotHrreion +[Dan Vanderkam]: https://github.com/danvk ## Version 11.11.1