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

Fix format ranges spanning newlines #131

Open jfschwarz opened 4 years ago

jfschwarz commented 4 years ago

Yet another small edge case bug I found: Italic text spanning a newline does not generate valid markdown.

Example: image Currently, this results in markdown like this

fir_st
se_cond

Rendering this will show underscores instead of italic text.

(Interestingly, I just found that GitHub suffers under the very same issue. 😆)

To fix this, we can split all open inline style and entity ranges when hitting a \n character. So now, the markdown produced for this example looks as follows

fir_st_
_se_cond
Rosey commented 4 years ago

In case you're wondering why this is still sitting! I checked it

Rosey commented 4 years ago

Ugh sorry on my phone and hit the "close and comment" button by accident as I was typing my comment ðŸĪŠ

Anyway: I checked the branch out and was looking at this plus your other pull request and because of the nested loop situation I was going to see if I could make some optimizations before merging. But I haven't actually had a lot of time to dig deeply, thus this PR sits here until I have the chance! 😃