kadikraman / draftjs-md-converter

Converts content from Draft.js blocks to Markdown and vice versa.
https://kadikraman.github.io/draftjs-md-converter/
MIT License
145 stars 37 forks source link

If a bold block has a leading or trailing space its not legal markdown #5

Closed bradbirnbaum closed 7 years ago

bradbirnbaum commented 8 years ago

If you are using draft-js and enable bold, then type a space, then your text and then another space before ending your block block you will get markdown that looks like this:

this is my text __ this is my bold text __ end of text

However since there is a space between the __ and the first char its not legal and won't render correctly.

kadikraman commented 8 years ago

Hi! Thanks for logging this as an issue 😄 I've written a test to highlight the bug, but I can't immediately think of a clean way to fix it. Going by how the markdown editor works in GitHub, I imagine the desired effect should be that any leading and trailing spaces around the word should be moved outside the markdown characters, so e.g. some __ bold __ text becomes some __bold__ text etc.

bradbirnbaum commented 7 years ago

Thanks @kadikraman for fixing the issue. Big help!