draft-js-utils
draft-js-utils copied to clipboard
draft-js-export-markdown plugin should escape all markdown characters from text blocks
Currently only characters _, ` and * are escaped. I think the plugin should either escape all markdown characters or none at all.
function encodeContent(text) {
return text.replace(/[*_`]/g, '\\$&');
}
In our project we need to escape all markdown characters when exporting, but we need to specifically exclude the characters which are escaped in this plugin, so we don't do double escapes.
Solution
My suggestion is that we use this plugin: https://www.npmjs.com/package/markdown-escapes
By default we escape the "escapes.default" and add an option to pass a paramter to escape commonmark and gfm to the stateToMarkdown method.