Syntax highlighting shard: Tartrazine

Version 0.6.4 is out and it’s (as far as I need it) feature complete. Feel free to use it for all you syntax-highlighting needs both as a library and as a CLI tool.

  • Over 200 languages supported
  • Over 300 themes
  • Renders to terminal and HTML
  • Packaged for Arch (and static binaries for linux available)

If someone uses it and needs something it doesn’t have, just let me know. Other than that, it’s done, done.

1 Like

I will use this for shards on the website that I am going to create in the future, although, i still not start doing it yet.

In fact, I was considering using prism before, which is a client-side (JavaScript) syntax highlighting engine, what are the benefits of server rendering over client rendering?

In my specific case, the main benefits are:

  • The results are more consistent than when using highlightjs which I was using earlier
  • I couldn’t find a way to make highlightjs give me anchors for each line of code so I could link to it
  • In highlightjs (don’t know prism) you need to know in advance in the template what languages you want to highlight to load the parsers

There are also things like not needing to trigger highlighting which sometimes made code “blink” on page load
but that’s minor and probably compensated by making your page a lot larger.

1 Like

As a heads up for anyone using it:

Today I did 2 releases (had more free time than expected) and now there are SVG and PNG formatters, meaning you can turn your files into a syntax-highlighted image

These formatters have some limitations because of the libraries or the format itself, but they are mostly ok. If someone ever really uses them they will improve.

3 Likes

New 0.12.0 release which updates data files to the latest chroma version, so it has a couple new themes and support for a few super obscure new languages.

Thanks to @zw963, markd now has optional support for rendering code blocks using tartrazine!

2 Likes

That’s awesome!

I wrote a program that uses markd to show highlighted markdown :-D GitHub - ralsina/markterm

So I guess if that will use tartrazine via markd, it means I can remove some custom code there :-)

1 Like

Hi, @ralsina , your blog website was down, at least from China.

It’s down for everyone, I am moving my office so it’s down until I have a new one :-)

May be a week or two from now.

1 Like

There is a new release.

The highlight is that it makes the crystal lexer more robust.

Lately, tartrazine uses crystal’s provided highlighter for crystal BUT that has the problem that it’s quite intolerant of invalid crystal (and even of some valid crystal :-) )

So, this catches errors and switches to the ruby lexer, which should do a decent job and is more robust.

1 Like