'Markdown to html javascript

I actually use TinyMCE (4.8.2) on my application for multiple fields. i automatize fields by json content from JIRA API. BUT... One of the field is already in Markdown from JIRA.

Then i have implemented plugin text_pattern from tinymce to configure the markdown symbol in javascipt. The problem still persist and the text will not changed to html without rewrite the text. I can't find issue, do you ?

function initMCEexact(e) {
    tinymce.init({
        mode: "exact",
        theme: "modern",
        plugins: 'textpattern, advlist',
        selector: 'textarea',
        elements: e,
        textpattern_patterns: [
            {start: '_', end: '_', format: 'italic'},
            {start: '*', end: '*', format: 'bold'},
            {start: 'h1. ', format: 'h1'},
            {start: 'h2. ', format: 'h2'},
            {start: 'h3. ', format: 'h3'},
            {start: 'h4. ', format: 'h4'},
            {start: 'h5. ', format: 'h5'},
            {start: 'h6. ', format: 'h6'},
            {start: '# ', cmd: 'InsertOrderedList'},
            {start: '* ', cmd: 'InsertUnorderedList'},
            {start: '*', cmd: 'InsertUnorderedList'},
            {start: '//brb', replacement: 'Be Right Back'}
        ]
    });
}

Expecting translation of markdown to HTML automatically.



Solution 1:[1]

It might be better if you use a Markdown to HTML converter. I recommend ShowdownJS. Just add it to your project with <script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.0/showdown.min.js"></script>, and then use this code:

var converter = new showdown.Converter();
var text = '# hello, markdown!';
var html = converter.makeHtml(text);

Solution 2:[2]

Really simple and possibly the smallest JavaScript MarkDown to HTML converter

Detailed list of JavaScript MarkDown converters

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2