markdown-draft-js
markdown-draft-js copied to clipboard
Fix format ranges spanning newlines
Yet another small edge case bug I found: Italic text spanning a newline does not generate valid markdown.
Example:
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
In case you're wondering why this is still sitting! I checked it
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! 😃