Description
Text inside an inline code span (wrapped in backticks) still has Markdown emphasis applied to it. If the code span contains underscores or asterisks that form an emphasis pair, the enclosed text is rendered italic/bold even though it's inside code.
Steps to reproduce
- Type
`The_brown_fox` into the editor.
- Observe that "brown" is rendered in italics.
Other examples that misbehave:
`a_b_c` → b italic
`foo**bar**baz` → bar bold
`see [x](y)` → link styling applied inside the code span
Expected
Inside an inline code span, all other inline Markdown (emphasis, strong, links) should be inert. Only the monospace/code styling should apply.
Cause
In src/markdownhighlighter.cpp, highlightInline() first formats inline code spans via the `([^`]+)` regex, then unconditionally runs inlineMarkup(text) over the entire line and re-applies bold/italic/link formats. The emphasis/link passes have no awareness of the code-span ranges found earlier, so any _, *, or [...]() sitting inside backticks is still matched and its setFormat() overrides the code format for the enclosed content.
Suggested fix
Compute the inline code-span ranges first, then skip any InlineMarkup item from inlineMarkup() whose span overlaps a code-span range (or mask backtick-delimited regions out of the string before running the emphasis/link regexes).
Description
Text inside an inline code span (wrapped in backticks) still has Markdown emphasis applied to it. If the code span contains underscores or asterisks that form an emphasis pair, the enclosed text is rendered italic/bold even though it's inside code.
Steps to reproduce
`The_brown_fox`into the editor.Other examples that misbehave:
`a_b_c`→bitalic`foo**bar**baz`→barbold`see [x](y)`→ link styling applied inside the code spanExpected
Inside an inline code span, all other inline Markdown (emphasis, strong, links) should be inert. Only the monospace/code styling should apply.
Cause
In
src/markdownhighlighter.cpp,highlightInline()first formats inline code spans via the`([^`]+)`regex, then unconditionally runsinlineMarkup(text)over the entire line and re-applies bold/italic/link formats. The emphasis/link passes have no awareness of the code-span ranges found earlier, so any_,*, or[...]()sitting inside backticks is still matched and itssetFormat()overrides the code format for the enclosed content.Suggested fix
Compute the inline code-span ranges first, then skip any
InlineMarkupitem frominlineMarkup()whose span overlaps a code-span range (or mask backtick-delimited regions out of the string before running the emphasis/link regexes).