#8404·tiptap

[Markdown] Code block inside an ordered list item gains a leading space on every parse

Author: ThomasBourgeoisCreated Sep 28, 2026Updated Sep 28, 2026
Labelsgood first issuearea: markdowncomplexity: easyimpact: medium

Affected Packages

@tiptap/extension-list, @tiptap/markdown

Tiptap Version

3.31.3

Browser Used

All (reproduced in Chromium and in Node with happy-dom)

What happened?

When Markdown with a fenced code block inside an ordered list item is parsed, each code line gets one extra leading space.

The error grows with every round-trip: getMarkdown() writes the extra space back, and the next setContent(..., { contentType: "markdown" }) adds one more. Saving the same document 3 times gives 4 extra spaces.

javascript
const input = "1. Item:\n\n   ```\n   code line\n   ```\n";
const editor = new Editor({ extensions: [StarterKit, Markdown], content: input, contentType: "markdown" });
// code block text: " code line"   (CommonMark reference: "code line")

editor.commands.setContent(editor.getMarkdown(), { contentType: "markdown" });
// "  code line"
editor.commands.setContent(editor.getMarkdown(), { contentType: "markdown" });
// "   code line"

The same happens with 10. markers.

Expected Behavior

The code block text is code line, as in the CommonMark reference implementation and in marked. Round-trips are stable.

Reproducible Example URL (Optional)

No response

Additional Context (Optional)

The cause looks like collectOrderedListItems in extension-list/src/ordered-list/utils.ts:

typescript
const contentIndent = indentLevel + marker.length + 1

This forgets the separator (. or )). For 1. , the content starts at column 3, but only 2 spaces are stripped. Using the real content offset fixes it in our tests:

typescript
const contentIndent = line.length - content.length

Possibly related: #8395 (same ordered-list tokenizer).