5

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.

2 Answers 2

6

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);
Sign up to request clarification or add additional context in comments.

2 Comments

Hello thanks for you're answer, the library is pretty cool but it's not adapted to my problem. In fact this library is maybe too restrictive...
the values to change are to restrictive, exemple for the library : # heading and in my case : h1. heading
3

Really simple and possibly the smallest JavaScript MarkDown to HTML converter

Detailed list of JavaScript MarkDown converters

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.