Cyjb.Markdown
1.0.2
dotnet add package Cyjb.Markdown --version 1.0.2
NuGet\Install-Package Cyjb.Markdown -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cyjb.Markdown" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Cyjb.Markdown --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Cyjb.Markdown, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Cyjb.Markdown as a Cake Addin
#addin nuget:?package=Cyjb.Markdown&version=1.0.2
// Install Cyjb.Markdown as a Cake Tool
#tool nuget:?package=Cyjb.Markdown&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Cyjb.Markdown
提供 Markdown 的解析和 HTML 渲染能力,基于 .NET 6。
使用方法
可以解析任意 Markdown 字符串
using Cyjb.Markdown;
using Cyjb.Markdown.Renderer;
// 将 Markdown 字符串解析成语法树。
Document doc = Document.Parse("This is a **markdown**");
// 将语法树渲染成 HTML 字符串。
HtmlRenderer renderer = new();
doc.Accept(renderer);
Console.WriteLine(renderer);
// <p>This is a <strong>markdown</strong></p>
可以通过 Document.Parse
方法的 options
参数指定需要使用的 Markdown 特性,所有支持的 Markdown 特性参见下文。
可以利用 SyntaxVisitor
遍历 Markdown 语法树,提供定制的逻辑。
支持的 Markdown 特性
- 支持完整的 CommonMark 0.30,具体请参见这里。
- 支持部分 GitHub Flavored Markdown (GFM),具体包括:
- 支持额外的列表样式:
a. item
、i. item
或α. item
,具体规范请参见这里。 - 支持数学公式:
$ $
或$$ $$
,具体规范请参见这里。 - 支持为标题、代码块、链接和图片添加属性:
{#id .class key=value}
,具体规范请参见这里。 - 支持为标题自动生成标识符,具体规范请参见这里。
- 支持直接将标题内容作为链接标签使用,具体规范请参见这里。
- 支持自定义容器:
:::detail :::
,具体规范请参见这里。
其它的建议用法
- 下标:
<sub> </sub>
。 - 上标:
<sup> </sup>
。 - 下划线:
<u> </u>
。
Markdown 解析用到了由 Cyjb.Compilers.Design 在设计时生成的词法分析器,因此预计不会提供运行时扩展 Markdown 特性的能力。
详细的类库文档,请参见 Wiki。
欢迎访问我的博客获取更多信息。
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Cyjb (>= 1.0.21)
- Cyjb.Compilers.Runtime (>= 1.0.16)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.