Robert
Robert

Reputation: 281

How to prevent rendering of headers in SimpleMDE markdown editor?

I made a customized version of wagtail-markdown so I can define the toolbar of the editor.

The editor used is SimpleMDE.

The MarkdownFiled is using a MarkdownTextarea widget. The widget can attach itself.

def render_js_init(self, id_, name, value):
        return 'simplemdeAttach("{0}", {1});'.format(id_, self.toolbar)

simplemdeAttach

/*
 * Used to initialize Simple MDE when Markdown blocks are used in StreamFields.
*/    

function simplemdeAttach(id, toolbar) {
        console.log('For id: '+ id + ' toolbar: ' + toolbar);
        var mde = new SimpleMDE({
            toolbar : toolbar,
            element: document.getElementById(id),
            autofocus: false,
            spellChecker: false,
        });
        mde.render();
        mde.codemirror.on("change", function(){
            $('#' + id).val(mde.value());
        });
    }

Editor in Wagtailadmin

widget at work

Manualy inserted hashes shouldn’t be rendered.

I investigated the javascript code of SimpleMDE but I can’t figure out how to prevent the rendering.

Does someone have a clue?

Regards,

Robert

Upvotes: -1

Views: 992

Answers (1)

Robert
Robert

Reputation: 281

I was completely in the wrong direction. Live rendering does not insert a header tag but it adds a class with a corresponding style which makes it look like a header.

Upvotes: 0

Related Questions