RazorComponents.Markdown
Razor component for Markdown rendering.
Install / Use
/learn @StardustDL/RazorComponents.MarkdownREADME
RazorComponents.Markdown
Razor component for Markdown rendering.
Online demo:
Features
- Abbreviations
- Auto identifiers
- Citations
- Custom containers
- Definition lists
- Emphasis extras
- Figures
- Footers
- Footnotes
- GridTables
- Mathematics
- Media links
- Youtube
- Bilibili
- Netease music
- Pipe tables
- Task lists
- Diagrams, flowcharts
- Auto links
- Smarty pants
- Emoji
- Code highlighting
- Delay rendering for less CPU intensive
- HTML Sanitizing to prevent XSS
Usage
Add the newest package on NuGet.
dotnet add package StardustDL.RazorComponents.Markdown
Install
This project is built on Modulight.
Here are the example codes, which based on the instructions from Usage and Use Razor Component Modules. See demo for details.
WebAssembly
// in Program.cs
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddModules(builder =>
{
builder.UseRazorComponentClientModules().AddMarkdownModule();
});
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
// Attention: RunAsyncWithModules
await builder.Build().RunAsyncWithModules();
}
Razor Pages
// in App.razor
<Modulight.Modules.Client.RazorComponents.UI.ResourceDeclare />
// in Startup: void ConfigureServices(ISeviceCollection services)
using StardustDL.RazorComponents.Markdown;
services.AddModules(builder => {
builder.UseRazorComponentClientModules().AddMarkdownModule();
});
// Generic hosting. (provided by package Modulight.Modules.Hosting, need to add this package)
// in Program: Task Main(string[] args)
using Microsoft.Extensions.Hosting;
await CreateHostBuilder(args).Build().RunAsyncWithModules();
Using
<StardustDL.RazorComponents.Markdown.MarkdownRenderer
Value="@MarkdownText"
Class="your class"
Style="your styles"
RenderInterval="@TimeSpan.FromSeconds(10)"/>
Parameters:
ValueRaw Markdown (String)Classclass attributeStylestyle attributeRenderIntervalDelay rendering interval (TimeSpan), defaultnullfor no delay.EnableCodeHighlightingHighlighing code blocks, defaulttrue.EnableDiagramsRendering diagrams, defaulttrue.EnableMathematicsRendering LaTex lines, defaulttrue.EnableHtmlSanitizingSanitizing the final HTML to prevent XSS, defaulttrue.
Preview
Here are some screenshots from the demo project.
Header

Code with highlighting

Extensions

Mathematics

Diagram

Dependencies
License
Apache-2.0
Related Skills
node-connect
349.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
