Question

I am using Pagedown version of Markdown and I have the script running successfully without any errors. Because I am using Grails I have to do all the conversion on the client(correct me if I am wrong).

To do this conversion I am using following script

   var converter = new Markdown.getSanitizingConverter();
    $.each($('.myclass'),function(key,value){
        console.log($(value).html());
        console.log(converter.makeHtml($(value).html()));
        alert(converter.makeHtml($(value).html()));
        $(value).html(converter.makeHtml($(value).text()))
    });

But all my text is being surrounded by <pre> and <code> tags One of the output of log statement is following

**Computers calculate numbers in Binary mode?(u0)**

gets converted to following rather then HTML

<pre><code> **Computers calculate numbers in Binary mode?(u0)**</code></pre> 
Était-ce utile?

La solution

Here is the working code:

var converter = new Markdown.getSanitizingConverter();

$.each($('.myclass'),function(key,value){
    p = converter.makeHtml($(value).text());

    $(value).html("");
    $(value).append(p);
});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top