You can use it as a library from Crystal, or you can use the markterm binary.
It can syntax highlight code (as long as you have chroma installed), it does the right thing when piped to another program, and it tries to look good but not gaudy.
What will I use it for?
Showing CLI program's help. I am using docopt lately and the
format of the docopt input is almost markdown. With a bit
of flair it can be both, and using markterm I can show it
in a terminal in a much nicer way than usual.
Extra: why am I starting so many projects lately?
Because it makes me happy
Because in most cases it's not code that will need maintenance.
I expect markterm to just work for the next 10 years without
me touching it, if needed.
I am working a bit (slowly) on Nicolino a static site generator written in Crystal. One of the things it does is, it renders markdown files.
Since the markdown usage is limited to, like, 3 lines, I thought
"Why not try all the markdown libraries and see which one is faster?"
So, I did.
The benchmark is simple:
An empty Nicolino site.
4000 simple markdown files (a few lorem ipsum paragraphs)
Nicolino compiled in release mode
Render the whole site 10 times, average the last 7 runs
Here is a chart showing the times in seconds for each library without the time that is used in other things (NOOP's time, which was 2.62 seconds).
So, luce is much, much, much slower, and crystal-cmark is the fastest. And cr-discount (MY OWN BINDING) is much slower than
the others, which is a bit disappointing.
On the other hand, there are two sides to optimizing. One is choosing the fastest library, the other is not caring if the
difference is small in absolute, even if it's large in relative.
What does that mean?
This is over 4000 documents.
So, while cr-discount is slower, it's still rendering 4000 documents in 0.66 seconds. That's 0.000165 seconds per document.
That's 1.65 tenths of a thousand of a second. That's over 6000
documents per second.
If the normal usecase was to render thousands of documents,
then that would make a difference. But it's not. It's usually 3 documents.
So, as long as cr-discount has any feature I need and it's not
in the other libraries, it's fine to use it, and the same
goes for the others (except luce, I guess, but still: 757 documents per second is not bad).
Update: Compiling discount with -O3 brings it down to 0.48, which is bettern than 0.66
but makes no difference for the conclusions.
Since everyone is in lockdown and I am no exception, I have spent some of my time doing
things in open source projects. Let me introduce you two new plugins for Nikola my favourite static site generator.
Yes, another markdown but, again, one with original ideas. In this case, myst has a lot of reStructured Text flavour,
with support for directives and roles.
Of course when using marko or myst in Nikola you also get support for shortcodes so they are extra-extensible here.
If you are looking for a static site generator, I am fairly sure "it doesn't support my
favourite markup language" is not a reason not to choose Nikola :-)