draft-js-utils icon indicating copy to clipboard operation
draft-js-utils copied to clipboard

Markdown doesn't support italic in the middle of words

Open SamiSaves opened this issue 5 years ago • 6 comments

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.

In source

SamiSaves avatar Apr 29 '19 14:04 SamiSaves

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?

sstur avatar Apr 29 '19 21:04 sstur

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.

SamiSaves avatar Apr 30 '19 05:04 SamiSaves

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 ?

krystofbe avatar Sep 15 '19 15:09 krystofbe

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.

sstur avatar Sep 15 '19 19:09 sstur

Any update on this? I'm having the same issue.

fedeciancaglini avatar Aug 25 '20 19:08 fedeciancaglini

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.

SamiSaves avatar Aug 26 '20 10:08 SamiSaves