Question

I'm using this jQuery markdown for my pages. The jQuery code is as follows:

var converter = new Markdown.Converter();
$(document).ready(function(e) {
    $('#content').html( converter.makeHtml($('#content').html()) );
    /* and some more */
});

This has been working perfectly. None of my pages had a blockquote until now. Today, I tried using a blockquote content and the page isn't parsing the HTML correctly.

The text is stored inside a MySQL table. Consider the following:

Just some

> random blockquote content. let's see if it works or not

This text is shown correctly on the markdown editor box:

WMD

But when opening it as a web-page (I use Opera; but the problem is still there in all other browsers, namely Firefox, Chrome and IE)

  1. The normal page shows

    page

  2. Opera Dragonfly

    dragonfly

  3. Raw text as page source

    source

P.S.: All images are thumbnails. Click for larger size.

Here is a fiddle link which shows the above problem: http://jsfiddle.net/atdEP/

Was it helpful?

Solution 2

Thanks to @Jay I've found a solution to the problem.

Instead of using .html() in the converter, it performs perfectly with .text().

var converter = new Markdown.Converter();
$(document).ready(function(e) {
    $('#content').html( converter.makeHtml($('#content').text()) );
    /* and some more --------------------- RIGHT HERE  >>>^ */
});

Here is the updated fiddle: http://jsfiddle.net/atdEP/1/

OTHER TIPS

I'm not familar with markdown, but i think you are picking up the > as an html entity I.E > and not a single character.

If I change your fiddle by hardcoding the string to the below, the > disappears from the results screen and the correct html appears. (tested in firebug)

<script type="text/javascript">
    var converter = new Markdown.Converter();
    $(document).ready(function (e) {
        $('#content').html(converter.makeHtml('> random blockquote'));
        /* and some more */
    });
</script>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top