Rosey / markdown-draft-js

A tool to convert content created in DraftJS to markdown and vice versa.
https://rosey.github.io/markdown-draft-js/
MIT License
318 stars 69 forks source link

markdown-to-draft: multi-line block quotes are squashed when preserveNewlines is `true` #108

Open Rosey opened 5 years ago

Rosey commented 5 years ago

See failing test here: https://github.com/Rosey/markdown-draft-js/pull/107/commits/71b848bf9e7c1b3ed123643d2bd6095e9ecce5b0

Would only be an issue for people using preserveNewlines: true as by default stripping those newlines is correct markdown behaviour.

However, we have a hack around preserving newlines when the option is turned on, and in this case it isn't working correctly. The case being where we have one single block quote with blank lines in between text.

Something like this for draft js should be generated for blank lines -

> test
>
>
>
> hello!

but instead we end up with something like

> test
> hello
petrmarecek commented 4 years ago

I have the same problem. Is there some solution?

Rosey commented 4 years ago

A solution needs to be written, it's a bit tricky but doable. remarkable exposes the number of "lines" as a variable even though it strips them so we'd need to update the parser to read the difference between line numbers and then re-add the newlines in. We do this already with regular paragraphs.

Seems straightforward enough but there are some gotchas that I encountered when I tried to do a hot fix so I put it off until I have more time to think about it properly. If anyone else wants to tackle they can also feel free of course!