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

draft-js-export-markdown plugin should escape all markdown characters from text blocks

Open SamiSaves opened this issue 5 years ago • 0 comments

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 source

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.

SamiSaves avatar Mar 21 '19 09:03 SamiSaves