Question

I'm trying to combine MarkItUp! and PageDown, and so far it's working great. I'm using MIU to create an editor and then giving it my custom function to parse the text with Markdown.Converter.js.

However, why I use my function, MIU doesn't load the template from the server, it simply creates a new iframe which is then used for preview. This is a problem because it's impossible to apply any CSS on that iframe due to XSS.

Is it possible to use client side parsing and custom template with MIU? Judging by the code, this doesn't seem to be an option, but perhaps someone has tried to solve this problem before? I also don't see an options to let me handle the preview entirely (which could also solve my problem)?

NB: The option in question is previewParser.

Was it helpful?

Solution

After some more digging around, I've come to the conclusion that this is not possible at the moment. So I've forked markItUp on github and created a patch which the author has kindly accepted.

Now you can use it like this:

var settings = mySettings;

settings.previewHandler = function(data) {
    var converter = new Markdown.Converter();
    $('#some-element').html(converter.makeHtml(data));
};

$('#some-input').markItUp(settings);

And you can style your preview however you want, or do whatever you want with the data in your previewHandlercallback.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top