Skip to content

A line break before an HTML block is lost on save #253

Description

@Azganoth

Summary

A paragraph line ending immediately before raw HTML loses its break when the file is saved. The two lines merge into one and the break does not come back. This is content loss rather than normalization: the document after reopening is missing a node it had before.

Steps to reproduce

  1. Open a document containing:

    Paragraph text before a custom tag.
    <garden-card data-bed="north">
  2. Save it without editing.

  3. Reopen the saved file.

Expected behavior

The break survives. The paragraph holds a text node, a hard break, and the raw HTML, as it did before the save.

Actual behavior

Measured against 9626471d by driving the editor mount used by the plugin tests:

  • Saved: Paragraph text before a custom tag. <garden-card data-bed="north">
  • Before: paragraph(text:"Paragraph text before a custom tag." hardbreak html)
  • After: paragraph(text:"Paragraph text before a custom tag. " html)

The hard break becomes a trailing space on the text node, and the node count drops.

corpus/commonmark/html.md carries this under Complete custom tags may not interrupt a paragraph, and it is why that file's document differs across one save.

Related context

Done when

  • The fixture above round-trips with its hard break intact.
  • Regression coverage asserts the document, not only the serialized bytes.
  • corpus/commonmark/html.md preserves its document across a save.

Notes, logs, screenshots

This is none of the three identity-gap causes #135 measured, and corpusRoundTrip.test.tsx is green on it. Convergence cannot see it: the document is already damaged by the first save, and every pass after that is stable. It surfaced only because #245 compared documents rather than serialized bytes, which is worth carrying into the regression coverage above.

Diagnosis

Not established. The break survives parsing and is lost on serialization, but which handler drops it was not isolated.

Out of scope

  • The table defect found alongside it, which is filed separately.
  • Whether raw HTML should be a distinct node at all.

Metadata

Metadata

Assignees

Labels

BugSomething isn't working

Projects

Status
In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions