Question

 ds fsd fsd gfdsds
    g
    ds g
    sd g
    dsg

► put returns between paragraphs

► for linebreak add 2 spaces at end

► _italic_ or **bold**

► indent code by 

the data mentioned above is in wmd text editor format that has been stored in my database. how to convert this data into html format when i am displaying this data in front end of any html pages or in any asp pages with label or any div or span.

The converted data must be like below that should be displayed.

 ds fsd fsd gfdsds
g
ds g
sd g
dsg

► put returns between paragraphs

► for linebreak add 2 spaces at end

italic or bold

► indent code by

Was it helpful?

Solution

Use markdown converter to convert markdown text to html data. Below is the code

    // create a pagedown converter - regular and sanitized versions are both supported
    var converter = new Markdown.Converter();
    // tell the converter to use Markdown Extra
    Markdown.Extra.init(converter);

    var $txtLabel = $('.cposttext');

    $.each($txtLabel, function (index, item) {
        $(this).html(converter.makeHtml($(this).html()));
    });
<script src="../Scripts/pagedown/Markdown.Extra.js" type="text/javascript"></script>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top