CommonMark.NET 使用教程
项目的目录结构及介绍
CommonMark.NET 项目的目录结构如下:
CommonMark.NET/
├── CommonMark.Console/
├── CommonMark.Tests/
├── CommonMark/
├── .gitattributes
├── .gitignore
├── CommonMark.NET.nuspec
├── CommonMark.sln
├── LICENSE.md
├── README.md
├── appveyor.yml
├── global.json
├── runtests.pl
目录介绍
- CommonMark.Console: 包含控制台应用程序的源代码。
- CommonMark.Tests: 包含项目的测试代码。
- CommonMark: 包含核心库的源代码。
- .gitattributes: Git 属性文件,用于指定文件的属性。
- .gitignore: Git 忽略文件,用于指定不需要跟踪的文件。
- CommonMark.NET.nuspec: NuGet 包的配置文件。
- CommonMark.sln: Visual Studio 解决方案文件。
- LICENSE.md: 项目的许可证文件。
- README.md: 项目的说明文件。
- appveyor.yml: AppVeyor 持续集成配置文件。
- global.json: 全局配置文件,用于指定 SDK 版本等。
- runtests.pl: 运行测试的 Perl 脚本。
项目的启动文件介绍
CommonMark.NET 的启动文件位于 CommonMark.Console
目录下。主要的启动文件是 Program.cs
,它包含了控制台应用程序的入口点。
// CommonMark.Console/Program.cs
using System;
using CommonMark;
namespace CommonMark.Console
{
class Program
{
static void Main(string[] args)
{
var markdown = "## Hello, World!";
var html = CommonMarkConverter.Convert(markdown);
System.Console.WriteLine(html);
}
}
}
启动文件介绍
- Program.cs: 控制台应用程序的入口点,包含
Main
方法,用于将 Markdown 文本转换为 HTML 并输出。
项目的配置文件介绍
CommonMark.NET 的配置文件主要包括 .gitattributes
、.gitignore
、CommonMark.NET.nuspec
和 appveyor.yml
。
配置文件介绍
- .gitattributes: 指定 Git 仓库中文件的属性,例如换行符的处理方式。
- .gitignore: 指定 Git 仓库中不需要跟踪的文件和目录。
- CommonMark.NET.nuspec: NuGet 包的配置文件,包含包的元数据和依赖项。
- appveyor.yml: AppVeyor 持续集成服务的配置文件,用于自动化构建和测试。
<!-- CommonMark.NET.nuspec -->
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>CommonMark.NET</id>
<version>0.15.1</version>
<authors>Knagis</authors>
<owners>Knagis</owners>
<licenseUrl>https://github.com/Knagis/CommonMark.NET/blob/master/LICENSE.md</licenseUrl>
<projectUrl>https://github.com/Knagis/CommonMark.NET</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Implementation of CommonMark specification in C# for converting Markdown documents to HTML. Optimized for maximum performance and portability.</description>
<releaseNotes>https://github.com/Knagis/CommonMark.NET/releases</releaseNotes>
<copyright>Copyright © 2014-2016 Knagis</copyright>
<tags>markdown commonmark</tags>
<dependencies>
<group targetFramework=".NETStandard1.0" />
</dependencies>
</metadata>
</package>
appveyor.yml
# appveyor.yml
version: 1.0.{build}
image: Visual Studio 2015
configuration: Release
platform: Any CPU
before_build:
- cmd