Skip to content

Literal ``` after a nested list corrupts a later code block in html → markdown #254

Description

@pchuri

Follow-up from #243 / #247.

Description
In html → markdown, if the text that follows a nested list inside a list item is a literal line of backticks (```), that line becomes a LIST_INDENT-prefixed continuation line. splitOnFences then treats it as a fence opener and pairs it with the next top-level fence. The real code block's body ends up outside the fence and goes through whitespace cleanup. This silently changes code.

This is not a regression from #247. main before #247 also corrupted this input, through its non-greedy list regex. #247's review listed it as a follow-up.

Repro (v2.25.8)

htmlToMarkdown('<ul><li>a<ul><li>b</li></ul>```</li></ul><pre><code>  indented\n    code   here</code></pre>')

Actual:

- a
  - b

  ```

```
indented
code here
```

Expected: the <pre> body stays byte-exact ( indented / code here), and the literal ``` stays as text, e.g. escaped as \`\`\`.

Notes

  • A top-level <p>```</p> followed by a code block has the same class of problem.
  • A likely fix: escape a leading backtick run in text (non-fence) lines before the cleanup chain runs. That way only fences the converter emitted itself can open a fence. Check storage → markdown for the same issue too.

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions