tags:

views:

624

answers:

3

What is the best implementation of Markdown for C or C++?

I found these via Google, and would appreciate comments about which ones work well and which ones don't (and which ones I may have missed):

+1  A: 

Googling a little more, i found that the Wikipedia page refers a Markdown Wiki which has several other implementation references in assorted languages and some tests too.

Very interesting, i had not read about Markdown before. Thanks.

nik
+14  A: 
  1. peg-markdown depends on GLib and other 3rd part tools. I've tested it, it works quite well.

    Advantages:

    • Dual-licensed under GPL and MIT.
    • Uses internally formal grammar, so easy to maintain and extend.

    Disadvantages:

    • Depends on GLib
    • Provides C API.
  2. Cpp-Markdown, Most C++ code but it is quite slow and little bit bloated. On the other hand it is quite easy to understand and modify, Depends on boost-1.35.

    Advantages

    • Depends only on boost
    • Written in C++, looks like less dangerous
    • Licensed under MIT.

    Disadvantages

    • Slow (it is still about 10 times faster then Perl implementation, but about 10 times slower than Discount)
  3. Discount, This is the code I use for my blog http://art-blog.no-ip.info/cppcms/blog and wiki http://art-blog.no-ip.info/wikipp/en/page/main. It is written by hardcore C programmer and quite hardly mantainable (even the developer activly maintains it).

    Advantages

    • Extremely fast
    • Written in pure C (no 3rd part dependencies).

    Disadvantages

    • Almost impossible to maintain (even I could remove/add some fatures).
    • Has only FILE API, so I should tweak the code to make it work with general buffer.
    • Licensed under 4 clause BSD license that is incompatible with GPL. It is problematic if you want to use it not as part of your GPL-ed software.

Why do I know them so much?

I'm developing CppCMS, So I need a good markdown to HTML convertor. When I piced one (Discount) It was only solution. Meanwhile I need to replace it due to licensing issues. But, I still quite like it because it is the fastest Markdown solution.

P.S.: If you want C++ wrapper for Discount, take a look on http://cppcms.svn.sourceforge.net/viewvc/cppcms/cms/trunk/cxxmarkdown/, It is not the latest version, but it is allready tweaked.

EDIT: I have just visited Discount site and I had found that it had added a non-FILE API as well. So now it is real library.

EDIT 2: If you find better implementation or write your own under FOSS license, let me know ;)

Artyom
I'm a huge fan of Discount, but thanks for the good overview of choices.
Telemachus
good overview, thanks!
peterchen
+1  A: 

I tried to use Cpp-Markdown in a wiki/cms of mine. It isn't really production-ready. It fails in a number of cases, e.g. links in titles, and I just found a case that results in a segfault. :-/

Timmmm