jsakamoto / Toolbelt.AspNetCore.MarkdownPages

Transform "text/markdown" response to HTML in ASP.NET Core application.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Toolbelt.AspNetCore.MarkdownPages NuGet Package

Transform "text/markdown" response to HTML in ASP.NET Core application.

How to use

Install Package

# Package manager Console
PM> Install-Package Toolbelt.AspNetCore.MarkdownPages

or

# .NET CLI
$ dotnet add package Toolbelt.AspNetCore.MarkdownPages

Enable "Markdown Pages" feature

At Configure method in Startup class, call UseMarkdownPages() extension method before middle wares that responding "text/markdown" contnets.

using Toolbelt.AspNetCore.MarkdownPages;
...
class Startup {
  public void Configure(IApplicationBuilder app){
    ...
    app.UseMarkdownPages();
    ...
    app.UseStaticFiles();
    ...
    app.UseMvc();
  }
}

After that, all responses which contntent type is "text/markdown" - not only static files but also MVC view result - are transform from markdown syntax text to HTML pages on the fly.

fig.1

fig.2

Inject custom CSS files

You can append custom CSS file when calling UseMarkdownPages() method with options.

  app.UseMarkdownPages(new MarkdownPagesOptions {
    CssLinks = {
      "/path/to/css-file1.css",
      "/path/to/css-file2.css",
      ...
    }
  });

CssLink property of MarkdownPagesOptions object has an item that the URL of default theme style CSS file.

If you want to overwrite all of CSS file links include default theme style, you can do it by creating new List<string> object and setting it to CssLinks property.

  app.UseMarkdownPages(new MarkdownPagesOptions {
    CssLinks = new List<string> {
      "/path/to/css-file1.css",
      "/path/to/css-file2.css",
      ...
    }
  });

License

Mozilla Public License 2.0

About

Transform "text/markdown" response to HTML in ASP.NET Core application.

License:Mozilla Public License 2.0


Languages

Language:C# 71.9%Language:CSS 28.1%