how to convert wmd format data to html format in front end asp page or html page

StackOverflow https://stackoverflow.com/questions/19550239

  •  01-07-2022
  •  | 
  •  

Вопрос

 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

Это было полезно?

Решение

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>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top