draft-js-utils
draft-js-utils copied to clipboard
Markdown doesn't support italic in the middle of words
Currently it is impossible to use italic in the middle of words, because the import plugin will render underscores in the middle of words as underscores instead of turning them into italic (As it should, see commonmark specs and github specs).
For example exporting "testitalicword" and then importing it back would result in test_italic_word
.
Possible fix
I tried fixing it by changing the italic from underscore to asterisk inthe draft-js-export-markdown plugin and for me it seemed to fix the issue.
OK. I'd be open to a PR to use asterisk, but it's a breaking change so perhaps only do it when necessary to disambiguate an italic within a word. Other ideas to minimize breakage?
Yeah it probably needs to be considered as a breaking change if someone trusts the plugin to generate underscores, but I doubt it will cause much breakage. Markdown should consider the asterisk and the underscore nearly identical, and the import plugin will work fine with both.
Just stumbled over this, any progress on this? Would you accept a PR changing the italic from underscore to asterisk in the draft-js-export-markdown ?
Yea, totally hit me with a PR. Would be happy to review!
[Edit] Both underscore and italics should work for italic in Markdown. If in doubt, do check how GH does it and let's try to mimic that behavior.
Any update on this? I'm having the same issue.
We decided to fork the repository and apply the fix in this pr manually https://github.com/sstur/draft-js-utils/pull/182
I never got any comments on PR so I never tried to fix the tests or tried to finalize it.