I have markdown in string property of my model and would like to render it onto page. If I have html in that same string property I would simply do:
@Html.Raw(Model.BodyHtml)
Is there a same thing if string contains Markdown rather than Html? Ie something like:
@Html.MarkdownToHtml(Model.BodyMarkdown)
The new @Html.RenderMarkdownToHtml()
API for this has just been added in v4.0.34+ that's now available on MyGet , which will let you render markdown with:
@Html.RenderMarkdownToHtml(Model.BodyMarkdown)
In earlier versions of ServiceStack you would call the Markdown implementation itself to render HTML and use the AsRaw()
extension method so the returned HTML isn't automatically encoded, eg:
@(new MarkdownSharp.Markdown().Transform(Model.BodyMarkdown).AsRaw())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.