Skip to content

read: two hard breaks in a row become a paragraph break #213

Description

@willkg

Two hard breaks in a row read back as a paragraph break. Found while working on #204; reproduced on main:

storage read writes publish sends
<p>a<br /><br />b</p> a␣␣\n␣␣\nb <p>a</p><p>b</p>

The second break's own two spaces make a line that holds nothing but whitespace, and Markdown reads that as a blank line, so one paragraph comes back as two. The editor writes this shape for Shift+Enter pressed twice.

Since #204 the same happens when a <br /> at the end of a bold run is followed by a <br /> (<p><strong>a<br /></strong><br />b</p>), because the edge break now moves out of the mark instead of being dropped.

Notes

  • A backslash hard break survives on a line of its own: a␣␣\n\\\nb publishes as <p>a<br />\n<br />\nb</p>. So the fix is probably to write every break after the first in a run as \ + newline.
  • Breaks are compared and trimmed as the literal " \n" in several places (renderInlineRun, renderMark's edge trim, renderCellLines' <br> substitution, the heading's <br /> substitution), so each place needs to recognise the second spelling too. Otherwise a mark's edge trim stops at the backslash.

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

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions