Skip to content

Inline code after a tilde is parsed with shifted backticks #4011

Closed

Description

@Hona

Marked version: 18.0.5

Markdown flavor: GitHub Flavored Markdown

Describe the bug

A literal tilde immediately followed by an inline code span causes the opening backtick to be consumed as text. Subsequent backticks are then paired incorrectly.

To Reproduce

  1. Create an empty directory and install Marked:

    npm init -y
    npm install [email protected]
  2. Save this as repro.mjs:

    import assert from "node:assert/strict"
    import { marked } from "marked"
    
    const markdown = "~`0.1576` to measurement-window-only `0.00092`"
    const expected = "<p>~<code>0.1576</code> to measurement-window-only <code>0.00092</code></p>\n"
    const actual = marked.parse(markdown)
    
    console.log(actual)
    assert.equal(actual, expected)
  3. Run node repro.mjs.

Actual output:

<p>~`0.1576<code>to measurement-window-only</code>0.00092`</p>

Expected behavior

The tilde should remain literal and both complete backtick pairs should be parsed as code spans:

<p>~<code>0.1576</code> to measurement-window-only <code>0.00092</code></p>

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