Search code examples
javascriptjquerypagedown

Using sanitize functions in PageDown


I have an issue with using getSanitizingConverter().When I try to use the following code:

var plainText;
var markdown = new Markdown.Converter();
var markdown = getSanitizingConverter();

plainText = markdownConverter.makeHtml("#Hi");

$(".hello").html(plainText);

I get an error saying Uncaught ReferenceError: getSanitizingConverter is not defined

My HTML:

<script src="markdown/converter.js"></script>
<script src="markdown/sanitizer.js"></script>
<script src="main.js"></script>

What am I doing wrong?

Here is a codepen RTC


Solution

  • It looks like the getSanitizingConverter function is placed on the Markdown variable. Try this:

    var plainText;
    var markdown = Markdown.getSanitizingConverter();
    
    plainText = markdown.makeHtml("#Hi");
    
    $(".hello").html(plainText);