Skip to content

datvm/LukeVo.Blazored.Showdown

Repository files navigation

Quickly convert Markdown to HTML and vice versa in Blazor using Showdown.js.

Demo

Demo: https://datvm.github.io/LukeVo.Blazored.Showdown/

Demo Screenshot

Installation

Install the NuGet package via the .NET CLI:

dotnet add package LukeVo.Blazored.Showdown

Setup

In your Program.cs, register the Showdown service:

builder.Services.AddBlazoredShowdown();

You can also configure the module path if you choose to host locally or pin to a specific version:

builder.Services.AddBlazoredShowdown(
	configure: opt =>
	{
		// The default url is https://cdn.jsdelivr.net/npm/showdown@latest/+esm
		opt.ModuleUrl = "<Module URL>";
	}
);

You can now inject IShowdownService and IShowdownServiceInProcess singletons into your components or services. You must first call InitializeAsync(), either at app start or any time before using other methods. Multiple calls are safe and subsequent calls after the first are no-ops.

var app = builder.Build();

await using (var scope = app.Services.CreateAsyncScope())
{
    var showdown = scope.ServiceProvider.GetRequiredService<IShowdownServiceInProcess>();
    await showdown.InitializeAsync();
}

await app.RunAsync();

Usage

See Demo Project.

About

A Blazor wrapper for ShowdownJS, A bidirectional Markdown to HTML to Markdown converter

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages