Stacks-Editor icon indicating copy to clipboard operation
Stacks-Editor copied to clipboard

Multiple headings on a single line without newline are broken between MD and RT modes

Open tmcentee opened this issue 3 years ago • 0 comments

Describe the bug When multiple heading HTML tags are inlined without a newline at the end of the line, switching between Markdown and Rich Text mode will mangle the resulting headings into a single invalid tag, breaking the output.

To Reproduce Steps to reproduce the behavior:

In Markdown mode, paste the following HTML into the editor. Ensure there are no newlines.

<h1>Heading1</h1><h2>Heading2</h2>

Switch to Rich Text mode and back to Markdown mode

You'll now see <h1Heading1h1h2>Heading2</h1Heading1h1h2>

Expected behavior I expect the round-trip to preserve the headings as they were at the start.

Hunches:

When a heading in pure HTML is serialized, if it doesn't have a newline at the end, it goes through the heading: method of defaultMarkdownSerializerNodes in markdown-serializer.ts. If it has a newline at the end, it'll instead go through html_block() of customMarkdownSerializerNodes in the same file.

Screenshots heading-merge-bug

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
  • Version 103

tmcentee avatar Jul 06 '22 15:07 tmcentee