From 0e7dafe7115a465eef5e22a5f16ecd4bb0a139bf Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Sat, 24 Aug 2024 22:33:24 -0300 Subject: [PATCH] Updated README --- README.md | 59 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 9b2cfa6..3252656 100644 --- a/README.md +++ b/README.md @@ -2,36 +2,11 @@ Tartrazine is a library to syntax-highlight code. It is a port of [Pygments](https://pygments.org/) to -[Crystal](https://crystal-lang.org/). Kind of. +[Crystal](https://crystal-lang.org/). -The CLI tool can be used to highlight many things in many styles. +It also provides a CLI tool which can be used to highlight many things in many styles. -# A port of what? Why "kind of"? - -Pygments is a staple of the Python ecosystem, and it's great. -It lets you highlight code in many languages, and it has many -themes. Chroma is "Pygments for Go", it's actually a port of -Pygments to Go, and it's great too. - -I wanted that in Crystal, so I started this project. But I did -not read much of the Pygments code. Or much of Chroma's. - -Chroma has taken most of the Pygments lexers and turned them into -XML descriptions. What I did was take those XML files from Chroma -and a pile of test cases from Pygments, and I slapped them together -until the tests passed and my code produced the same output as -Chroma. Think of it as *extreme TDD*. - -Currently the pass rate for tests in the supported languages -is `96.8%`, which is *not bad for a couple days hacking*. - -This only covers the RegexLexers, which are the most common ones, -but it means the supported languages are a subset of Chroma's, which -is a subset of Pygments'. - -Currently Tartrazine supports ... 247 languages. - -It has 331 themes (63 from Chroma, the rest are base16 themes via +Currently Tartrazine supports 247 languages. and it has 331 themes (63 from Chroma, the rest are base16 themes via [Sixteen](https://github.com/ralsina/sixteen) ## Installation @@ -58,7 +33,7 @@ $ tartrazine whatever.c -l c -t catppuccin-macchiato --line-numbers -f terminal Generate a standalone HTML file from a C source file with the syntax highlighted: ```shell -$ tartrazine whatever.c -l c -t catppuccin-macchiato --line-numbers \ +$ tartrazine whatever.c -t catppuccin-macchiato --line-numbers \ --standalone -f html -o whatever.html ``` @@ -87,3 +62,29 @@ puts formatter.format(File.read(ARGV[0]), lexer) ## Contributors - [Roberto Alsina](https://github.com/ralsina) - creator and maintainer + +## A port of what? Why "kind of"? + +Pygments is a staple of the Python ecosystem, and it's great. +It lets you highlight code in many languages, and it has many +themes. Chroma is "Pygments for Go", it's actually a port of +Pygments to Go, and it's great too. + +I wanted that in Crystal, so I started this project. But I did +not read much of the Pygments code. Or much of Chroma's. + +Chroma has taken most of the Pygments lexers and turned them into +XML descriptions. What I did was take those XML files from Chroma +and a pile of test cases from Pygments, and I slapped them together +until the tests passed and my code produced the same output as +Chroma. Think of it as [*extreme TDD*](https://ralsina.me/weblog/posts/tartrazine-reimplementing-pygments.html) + +Currently the pass rate for tests in the supported languages +is `96.8%`, which is *not bad for a couple days hacking*. + +This only covers the RegexLexers, which are the most common ones, +but it means the supported languages are a subset of Chroma's, which +is a subset of Pygments' and DelegatingLexers (useful for things like template languages) + +Then performance was bad, so I hacked and hacked and made it +significantly [faster than chroma](https://ralsina.me/weblog/posts/a-tale-of-optimization.html) which is fun. \ No newline at end of file