Skip to content

Inline code spans still get emphasis applied: The_brown_fox renders "brown" italic #47

Description

@jasonzondor

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

  1. Type `The_brown_fox` into the editor.
  2. 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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions