ProseMirror / prosemirror-markdown

ProseMirror Markdown integration
https://prosemirror.net
MIT License
344 stars 81 forks source link

Handling of `softbreak` is weird #91

Closed segevfiner closed 1 year ago

segevfiner commented 1 year ago

Currently prosemirror-markdown converts a softbreak to a \n in the text node, this seems to render as a line break when initially viewed, but is stripped away on the first edit of that text node. I think this is weird and unintuitive. How should this be handled better?

Recording 2023-04-03 at 21 39 05

marijnh commented 1 year ago

We could just convert them to spaces? Soft breaks don't really do anything more than spaces in default CommonMark, do they?

segevfiner commented 1 year ago

Some parsers convert them to hardbreaks while some to a single space. GitHub does hardbreaks, VS Code Markdown preview does space.

marijnh commented 1 year ago

I don't think it's reasonable to try to preserve them in the ProseMirror document. You can configure your markdown parser to convert them to hard breaks if you want, but converting them to a space seems reasonable default behavior. Does that sound workable?

segevfiner commented 1 year ago

I guess so. But I think it needs to be done by overriding the softbreak rule of prosemirror-markdown.

P.S. It would be interesting to have the ability to rewrap the Markdown text on output to some line width using soft breaks. I wonder if this can be done.