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

Don’t apply block styles to empty blocks #62

Closed davidmfoley closed 6 years ago

davidmfoley commented 6 years ago

Turning on "header-3" mode in draft, then adding the following (note blank lines):


Header 1

Header 2

would convert to:

### ### Header 1

### ### Header 2

With this PR, the result is:

### Header 1

### Header 2

Not familiar at all with this codebase; hopefully I didn't introduce other errors with this change.

Rosey commented 6 years ago

Oh interesting find, thank you! Hopefully the tests would catch anything if you had introduced a bug, but I can think of a couple cases where this might break so I'm going to try it out real quick before merging and I'll add some additional commits if necessary!

(my thinking is that when preserveNewlines: true is set we may want to style the blocks if they are their own line, so that a blockquote remains a blockquote even if blank, if that makes sense)