Skip to content
ASP.NET MVC view engine and HTML helper that renders Markdown.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Assets
Library
.gitignore
MarkdownMvc.sln
README.md
Rules.ruleset

README.md

logo

MarkdownMvc

ASP.NET MVC view engine and HTML helper that renders Markdown.

View Engine

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):

HTML Helper

@using MarkdownMvcLibrary

@{
    ViewBag.Title = "My Stupid Page";
    Layout = "~/Views/Shared/Layout.cshtml";
}

<h1>Here, have some Markdown:</h1>

@Html.Markdown("crazy-markdown-content.md")
You can’t perform that action at this time.