Markdown Implementations for C/C++ [closed]

2019-01-30 00:20发布

问题:

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):

  • peg-markdown
  • Discount
  • Cpp-Markdown
  • libsoldout (formerly libupskirt)

回答1:

  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).
    • Actively maintained
    • Has permissive 3 clause BSD license

    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 picked one (Discount), it was the only solution. Since then I've needed to replace it due to licensing issues. That said, 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 already 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 ;)

EDIT 3: as cloose commented, discount had changed the license to 3 clause BSD.



标签: c++ c markdown