Hard line breaks always also add newline #80
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I noticed that hard line breaks always add a newline character, which breaks stuff when set `preserveWhitespaces: 'full'´ for paragraphs.
Consider this:
will result in
And then serialized as:
which results in this:
My use case:
keep differences of markdown files after editing as small as possible, especially custom formatting (from external editors). E.g.:
without
preserveWhitespaces: 'full'this would result inThe rendered version would look the same, but the source file is different and may be harder to read.
I don't quite understand the problem here. If I add a test for the document you show (in attached patch), that content seems to round-trip just fine, without any extra newlines being inserted.
It does not happen when using the provided markdown parser, but if happens if you set the parse options / parse rules of paragraphs to
preserveWhitespace: true.e.g. you want to keep the formatting of a markdown file after a roundtrip you need to keep any additional tabs and spaces and also newlines "soft brakes" like:
should stay like this after a roundtrip and not result in
even if this is syntactically the same.
So the previous example results in:
which is this prosemirror state:
doc(p("hello", br(), "\nworld")).And that state would currently be serialized as
(note the additional newline).
See the testcase in the PR:
That's a DOM parser option, though. How does that effect Markdown deserializing?
As I said I do not use the provided parser, but plain
markdown-itas the project uses quite a lot markdown extensions.So this is only a problem if you use the
to_markdownpart of this nice project together with custom markdown parsing.(I can understand if you decide that this is a won't fix)
Ah, all right. I think this is something you'll have to address in your custom parser then.