ASP.NET MVC view engine and HTML helper that renders Markdown.
Register the engine on your Global.asax's Application_Start:
ViewEngines.Engines.Add(new MarkdownViewEngine());
You can also pass a custom CSS URL to be used if you want:
ViewEngines.Engines.Add(new MarkdownViewEngine("/css/markdown.css"));
The views are searched in ~/Views/{controller name}/{action name or view name if provided}.md
.
The rendered HTML is simple, it's a sum of:
<!doctype html>
;<style>a custom css</style>
(sample) or<link rel="stylesheet" href="the provided CSS URL">
;<title>View's filename (without extension)</title>
;- and the parsed Markdown content.
Also, don't forget to set the "Build Action" of your ".md" files to "Content" (else they won't be copied when publishing):
@using MarkdownMvcLibrary
@{
ViewBag.Title = "My Stupid Page";
Layout = "~/Views/Shared/Layout.cshtml";
}
<h1>Here, have some Markdown:</h1>
@Html.Markdown("crazy-markdown-content.md")