DWQA QuestionsCategory: Development ToolHow does text editor integrate markdown?
Keven Xiaowei asked 1 month ago

In developing a blog site, I used a text editor such as bootstrap WYSIWYG to add articles. Q: how to integrate markdown with a text editor like bootstrap WYSIWYG? It is required to support markdown syntax in the editor input box after integration.

11 Answers
mengfeng answered 1 month ago

There are two JavaScript libraries you can use to handle mardown
markdown.js https://github.com/mengfeng/zths/blob/master/js/markdown.js
to-markdown.js https://github.com/mengfeng/zths/blob/master/js/to-markdown.js
Similar usage:

var htmltomarkdown=function(html){
    //toMarkdown is defined in to-mardown.js
    //console.log(html);
    return toMarkdown(html);
};

var markdowntohtml=function(text){
    //markdown is defined in markdown.js
    //console.log(text);
    var html=markdown.toHTML(text);
    //console.log(html);
    return html;
};
bf answered 1 month ago

imagehttps://stackedit.ioThat way?

Integ answered 1 month ago

It is recommended to find a markdown editor to use directly.
If you want to write markdown in the WYSIWYG editor, you need to make sure that it doesn’t directly convert what you write into HTML.
Then the MD text in the editor input box is passed to the back end for parsing and then converted to HTML.

MoMaek years answered 1 month ago

It’s better to use markdown to edit directly?https://github.com/jbt/markdown-editor