How do you apply Markdowndeep to text in view using Razor syntax?

725 views Asked by At

So I followed a tutorial setting up a Markdowndeep editor using MVC and the editor and preview work just fine. The tutorial didn't mention how to render specific text on a page using Markdowndeep though. So I did a few Google searches thinking I'd find an obvious answer but to my surprise I didn't.

Can someone show me an example on how to render a portion of text using Razor?

2

There are 2 answers

0
Noah R On

I figured out the syntax. It was @Html.Markdown(Model.Body) You must have Markdown Helper installed though.

0
LucasS On

Another option is to force Razor to return the RAW Html. If we extend the MarkDownDeep Example, we get the following:

// Instantiate
var md=new MarkdownDeep.Markdown();

// Set options
md.ExtraMode=true;

// Translate
var html=md.Transform(plaintext);

<div>@Html.Raw(html)</div>

and your markdown as HTML should be in the div!