Skip to content
프로젝트

소개

Markdown 문서를 HTML로 변환하는 C# 기반 CommonMark 사양 구현입니다. 최고의 성능과 이식성을 위해 최적화되었습니다.

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
-1
in 15 days
-1
in 1 month
-2

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

CommonMark.NET is no longer maintained. If you find it does not meet your needs, you might want to check out Markdig.


Build status

CommonMark.NET

Implementation of CommonMark specification (passes tests from version 0.27) in C# for converting Markdown documents to HTML.

The current version of the library is also available on NuGet.

Usage

To convert Markdown data in a stream or file:

using (var reader = new System.IO.StreamReader("source.md"))
using (var writer = new System.IO.StreamWriter("result.html"))
{
  CommonMark.CommonMarkConverter.Convert(reader, writer);
}

To convert data stored in a string:

var result = CommonMark.CommonMarkConverter.Convert("**Hello world!**");

See the wiki for an example how the parser can be extended with additional logic.

Important: The converter does not include any HTML sanitizing.

Installation via NuGet

Install-Package CommonMark.NET

Compatibility

The library uses no references except for System - it has no external dependencies. It is cross compiled to:

  • .NET Framework 2.0
  • .NET Framework 3.5 Client Profile
  • .NET Framework 4.0 Client Profile
  • .NET 4.0 Portable Class Library
    • .NET Framework 4.0 Client Profile
    • Silverlight 5
    • Windows 8
    • Windows Phone 8.1
    • Windows Phone Silverlight 8
    • Xamarin.Android
    • Xamarin.iOS
  • .NET 4.5 Portable Class Library (Optimized)
    • .NET Framework 4.5
    • Windows 8
    • Windows Phone 8.1
    • Windows Phone Silverlight 8
    • Xamarin.Android
    • Xamarin.iOS
  • .NET Framework 4.5 (Optimized)
  • .NET Core 1.0 (.NET Standard 1.0)

For working with the source code you will need Visual Studio 2015 or newer (Community edition is supported).

Performance

Using a simple tool to compare the performance of various Markdown implementations for .NET yields the following results:

 CommonMark.NET 0.4.1      4 ms   7%      

CommonMarkSharp 0.3.2     30 ms   46%
   MarkdownSharp 1.13     55 ms   84%     (might not conform to CommonMark specification)
     MarkdownDeep 1.5      7 ms   11%     (might not conform to CommonMark specification)
  MoonShine (sundown)      3 ms    6%     (wrapper for a native x86 .dll)
             Baseline     65 ms   100%    (used to compare results on different machines)

This benchmark is very simple and tests the processing of the CommonMark specification document itself (a 115 KB file). The results are provided just for a high-level comparison.

Reliability

The parser uses algorithms that completely avoid recursion so even specifically crafted input documents will not cause exceptions and will be rendered correctly. This is important because a StackOverflowException cannot be caught and will bring down the entire process.

References

This library is based on a port of the reference implementation in C, available on jgm/cmark repo. It follows the same approach - the source is parsed into a syntax tree that can be used to add custom processing if the application needs it and then formatted into HTML.

Running tests

All tests from spec.txt are merged into the unit testing project and can be executed from within Visual Studio.

The project also includes a slightly modified version of runtests.pl for compatibility with the original implementation. Use CommonMark.Console.exe --perltest as the argument to runtests.pl so that the application can correctly handle input from the Perl script.

관련 프로젝트 살펴보기

불러오는 중…