CommonMarkSharp

I have now published the first version of CommonMarkSharp. All tests from the spec pass.

The project at GitHub is here: https://github.com/MortenHoustonLudvigsen/CommonMarkSharp

The NuGet package is here: http://www.nuget.org/packages/CommonMarkSharp/

I hope it will be found to be useful.

/Morten

Well, I just had to do it - run a benchmark comparing the two :smile:

So I ran both libraries against the CommonMark spec.txt file.

// results
  CommonMark.NET     47ms
 CommonMarkSharp  15276ms

// code
      System.IO.TextReader a;
      System.IO.TextWriter b;
     (a, b) => CommonMark.CommonMarkConverter.Convert(a, b),
     (a, b) => new CommonMarkSharp.CommonMark().RenderAsHtml(a, b)

You’re absolutely right. There are some performance issues.

They are in the block handling part of the parser. I have not focused on performance, but have tried to make an extensible design. Now that all the tests pass, I will look at improving the block handling, and hopefully improve performance and extensibility.

CommonMarkSharp version 0.1.0 has been published.

There are still some performance issues, but performance has improved:

CommonMarkSharp 0.1.0   353ms

My thanks to Knagis for the tool to measure performance (https://github.com/Knagis/CommonMarkBenchmark).

My focus now is to tidy up the code, make the parser more extensible and document the extensibility features.

:slight_smile: The race is on! A healthy competition is never a bad thing. Although we should probably get some documents more suited for the benchmark.

 CommonMark.NET 0.1.2     15 ms   23%
 CommonMark.NET 0.1.0     56 ms   83%
CommonMarkSharp 0.1.0    276 ms   409%
   MarkdownSharp 1.13     56 ms   83%     (might not conform to CommonMark specification)
     MarkdownDeep 1.5      8 ms   11%     (might not conform to CommonMark specification)
             Baseline     67 ms   100%    (used to compare results on different machines)

I honestly think the spec is a very good choice. It covers all the syntax elements. However it could be interesting to see how they perform with other documents.

BTW

You might like to look at the test project for CommonMarkSharp. It creates unit tests for each spec in spec.txt using a T4 template (Specs.tt), so they can be run from the test explorer. The spec is retrieved using bower, so getting the newest spec is just a question of calling:

bower update

And running custom tools on Specs.tt.

This should be easy to adjust for your project, if you want. :slight_smile:

CommonMarkSharp version 0.1.1 has been published.

Once again, performance has improved:

CommonMarkSharp    109ms

CommonMarkSharp version 0.2.1 has been published.

Once again, performance has improved:

       Baseline     51  100 %
CommonMarkSharp     23   45 %
 CommonMark.NET      6   13 %
  MarkdownSharp     35   69 %
   MarkdownDeep      6   11 %