Skip to content

text-editor changes the meaning of Markdown on save (empty sub-items, lists with 10+ items, escaped list markers) #3583

Closed

Description

@richardguenther

Initial Checklist

  • I understand this is a bug report and questions should be posted in the Community Discussions
  • I searched issues and couldn’t find anything (or linked relevant results below)

Bug Description

(Pi and Opus 5.5 helped a lot in finding and describing this behavior)

The Markdown round trip of the text editor (parse on load, serialise on save) silently changes the meaning of
ordinary Markdown in four cases. All appear in pages written by Nextcloud Text; three can also be produced by typing
or pasting in the editor itself. There is no warning, and every peer in the Yjs room saves the changed text.

Measured on copies of a migrated school-association wiki (97 pages): 13 change meaning on the first save.

Versions

  • OpenCloud rolling 8.0.1 with its bundled Web 8.0.0, relay opencloudeu/yjs:1.0.0
  • Web 8.1.0 (release asset via WEB_ASSET_CORE_PATH), relay opencloudeu/yjs:1.1.0
  • Google Chrome 154 (headless), macOS
  • @tiptap/markdown 3.31.4 and marked 17.0.6 as resolved by @opencloud-eu/web-pkg 8.0.0 and 8.1.0 (the versions inside the released host bundle were not checked)

Related: #3434 (image embeds deleted on save, the same round-trip problem).

Reproduction Steps

Upload each file as x.md, open it in the text editor, type one character at the end, save, reload.

1. An empty sub-item deletes its parent item

- Punkt mit leerem Unterpunkt
  - 
- Weiter
  • Web 8.0: saved as - Weiter; the first item and its text are gone.
  • Web 8.1: hydration fails ([yjs] hydration failed: TransformError: Invalid content for node listItem); the editor
    shows an empty, read-only page (viewers too) and "Preparing this file for collaborative editing failed. Please
    reload.", which does not help. A heading in a list item (- # Titel) fails the same way.
  • Cause: Markdown reads - below - text as a setext heading underline, so the list item starts with a heading.
    The schema (listItem: paragraph block*) does not allow that; the Yjs binding drops the whole node.
  • In the editor: type - Punkt, Enter, Tab, then save: the empty nested item is serialised as - and the page
    loses "Punkt" on the next load.

2. A right-aligned ordered list loses item 10 and later

 1. eins
 2. zwei
 3. drei
 4. vier
 5. fünf
 6. sechs
 7. sieben
 8. acht
 9. neun
10. zehn

Saved as items 1–9; 10. zehn is gone. (marked ends the list when the indentation of the marker changes.)

3. Escaped list markers at a line start lose their escape

\- kein Aufzählungspunkt, nur ein Strich

1\. kein Listenpunkt

1. \-

Saved as - kein Aufzählungspunkt…, 1. kein Listenpunkt and 1. -. The editor shows text, the next load shows a
bullet list, an ordered list, and an empty nested list. The serialiser does not escape a paragraph whose text starts
with -, +, * or <digits>..

The editor produces this itself:

  • type 1x. Mai ist Sportfest, then delete the x → saved as 1. Mai ist Sportfest → an ordered list on reload;
  • paste the plain text 1. Mai ist Sportfest into an empty paragraph → same.

4. Harmless but noisy: & is written as &amp;; > [!NOTE] becomes > \[!NOTE\] (the callout is lost);
<https://example.org> becomes [https://example.org](https://example.org); an empty ## heading is dropped.

Expected Outcome

What the editor shows is what the next load shows. Where that is impossible (a construct the schema cannot hold),
the editor should keep the source or at least refuse to save silently.

Suggested fixes

  1. Serialiser: escape a leading -, +, *, #, > or <digits>. / <digits>) in paragraph text (CommonMark
    §2.4 backslash escapes), as prosemirror-markdown does with esc().
  2. Parser: map a list item whose first block is not a paragraph (setext heading from an empty sub-item) to
    paragraph + empty nested list, instead of producing schema-invalid content that the Yjs binding drops; at least
    fail loudly instead of dropping content.
  3. Ordered lists: normalise marker indentation before tokenising, or set marked's list handling so that 9. and
    10. stay one list.
  4. A round-trip check in the editor (parse(serialise(doc)) equals doc) before every save would turn all of these
    into a visible warning instead of data loss.

Actual Outcome

Content is lost or changes meaning silently on save, as shown per case under Reproduction Steps: the parent item
of an empty sub-item disappears (Web 8.0) or the page cannot be opened at all (Web 8.1, hydration error); items 10+
of a right-aligned ordered list vanish; escaped list markers turn into lists. Every peer in the Yjs room saves it.

Our workaround (Barkhof Pad extension): a word check opens pages whose words the editor would drop read-only (they
are fixed by hand), and holds back a save whose next load would drop words. A paragraph that starts with a space
right after a list is a further case: it is serialised as a lazy continuation, becomes a second paragraph of the
last item, which the schema rejects, and is dropped (Web 8.0; on Web 8.1 only after a task list, where the
paragraph loses its first letter).

Activity

  1. self-assigned this
    on Oct 7, 2026
  2. JammingBen commented on Oct 13, 2026

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions