Skip to content

fix(editor): keep task list content and indented code fences in markdown - #3616

Merged
JammingBen merged 2 commits into
mainfrom
fix/tiptap-md-task-lists
Oct 13, 2026
Merged

JammingBen merged 2 commits into
mainfrom
fix/tiptap-md-task-lists

Conversation

@JammingBen

@JammingBen JammingBen commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Description

Fixes content that gets lost or changed when a markdown file is opened in the editor and saved.

Fenced code blocks indented 1-3 spaces were dropped by tiptap. They are now parsed as code blocks.

Task lists (markdownTaskList.ts): tiptap counts a tab as one character of indentation and cuts a fixed two characters from every line nested in a task item. That loses the first letter of lines indented by one space and the content of tab indented lines. Leading tabs are now expanded, and lines indented less than the item's content are moved to it. Tabs inside code blocks are kept.

The workarounds can be removed once the referenced tiptap issues are fixed upstream (see linked issues in code).

Related Issue

How Has This Been Tested?

mkdir md-3616 && cd md-3616
printf -- ' ```\n code\n ```\n' > 01-indented-fence.md
printf -- '  ~~~\n   code\n    x\n  ~~~\n' > 02-indented-tilde-fence.md
printf -- '- a\n ```\n code\n ```\n' > 03-indented-fence-after-list.md
printf -- '- [ ] task\n\n x paragraph\n' > 04-task-paragraph-1-space.md
printf -- '- [ ] a\n b\n c\n' > 05-task-lines-1-space.md
printf -- '- [ ] a\n # h\n' > 06-task-heading-1-space.md
printf -- '- [ ] a\n ```\n code\n   x\n ```\n' > 07-task-code-1-space.md
printf -- '- [ ] a\n  - [ ] b\n\n   x c\n- [ ] d\n' > 08-nested-task-paragraph.md
printf -- '- [ ] a\n\tb\n' > 09-task-line-tab.md
printf -- '- [ ] a\n\t- [ ] b\n' > 10-nested-task-tab.md
printf -- '- [ ] a\n\t```js\n\tconst x = 1\n\t```\n' > 11-task-code-tab.md
printf -- '- [ ] a\n\n\t```\n\tcode\n\t```\n- [ ] b\n\nafter\n' > 12-task-code-tab-blank-line.md
File main this PR
01, 02 Code block becomes escaped paragraph text, e.g. \`\`\` code \`\`\` Code block
03 Code block is dropped, only - a is left Code block after the list
04 x paragraph becomes paragraph x paragraph in the task item
05 b and c are dropped b and c in the task item
06 Heading becomes the text h Heading h in the task item
07 Code block becomes inline code `ode x` Code block code / x in the task item
08 x c becomes c x c in the outer task item
09 b is dropped b in the task item, with leading spaces (see known limitations)
10 Nested task becomes the text [ ] b Nested task item b
11 Code block becomes inline code `js onst x = 1` js code block const x = 1
12 Code block becomes inline code `ode` Code block code in the first task item

Known limitations

These task list inputs are still not kept as they are. They are no regressions, main handles them the same or worse. They come from tiptap's task list tokenizer (ueberdosis/tiptap#7909) and are left for a follow-up:

  • Code in a fence indented less than the fence is lost. - [ ] a\n ```\n x\n ```\n loads as an empty code block, and saving drops the x.
  • A task item indented one column past its parent loses its marker. - [ ] a\n - [ ] b\n loads b as the paragraph text [ ] b instead of a task item. The same happens to c in - [ ] a\n - [ ] b\n - [ ] c\n. In CommonMark these items are siblings of their parent.
  • A tab indented line below a task item keeps leading spaces. - [ ] a\n\tb\n loads b as the paragraph text b, which is shown shifted to the right and saved as b. On main the line is dropped. fix(editor): keep markdown lists and paragraphs stable across roundtrips #3614 fixes this, it strips the indentation of paragraph lines.

@JammingBen
JammingBen merged commit 8a48993 into main Oct 13, 2026
31 checks passed
@JammingBen
JammingBen deleted the fix/tiptap-md-task-lists branch October 13, 2026 06:29
@openclouders openclouders mentioned this pull request Oct 13, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants