mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-13 23:12:24 +00:00
82 lines
20 KiB
HTML
82 lines
20 KiB
HTML
<!DOCTYPE html><html><head><style>.e {color: #aa0000;background-color: #ffaaaa;}.b {background-color: #f0f3f3;tab-size: 8;}.k {color: #006699;font-weight: bold;}.kp {font-weight: 600;}.kt {color: #007788;}.na {color: #330099;}.nb {color: #336666;}.nc {color: #00aa88;font-weight: bold;}.nc {color: #336600;}.nd {color: #9999ff;}.ne {color: #999999;font-weight: bold;}.ne {color: #cc0000;font-weight: bold;}.nf {color: #cc00ff;}.nl {color: #9999ff;}.nn {color: #00ccff;font-weight: bold;}.nt {color: #330099;font-weight: bold;}.nv {color: #003333;}.ls {color: #cc3300;}.lsd {font-style: italic;}.lse {color: #cc3300;font-weight: bold;}.lsi {color: #aa0000;}.lso {color: #cc3300;}.lsr {color: #33aaaa;}.lss {color: #ffcc33;}.ln {color: #ff6600;}.o {color: #555555;}.ow {color: #000000;font-weight: bold;}.c {color: #0099ff;font-style: italic;}.cs {font-weight: bold;}.cp {color: #009999;font-style: normal;}.gd {background-color: #ffcccc;border: 1px solid #cc0000;}.ge {font-style: italic;}.ge {color: #ff0000;}.gh {color: #003300;font-weight: bold;}.gi {background-color: #ccffcc;border: 1px solid #00cc00;}.go {color: #aaaaaa;}.gp {color: #000099;font-weight: bold;}.gs {font-weight: bold;}.gs {color: #003300;font-weight: bold;}.gt {color: #99cc66;}.gu {text-decoration: underline;}.tw {color: #bbbbbb;}.lh {}</style></head><body><pre class="b" ><code class="b"><span class="gh"># TARTRAZINE</span><span class="t">
|
|
</span><span class="t"></span><span class="t">
|
|
</span><span class="t">Tartrazine</span><span class="t"> </span><span class="t">is</span><span class="t"> </span><span class="t">a</span><span class="t"> </span><span class="t">library</span><span class="t"> </span><span class="t">to</span><span class="t"> </span><span class="t">syntax-highlight</span><span class="t"> </span><span class="t">code.</span><span class="t"> </span><span class="t">It</span><span class="t"> </span><span class="t">is</span><span class="t">
|
|
</span><span class="t">a</span><span class="t"> </span><span class="t">port</span><span class="t"> </span><span class="t">of</span><span class="t"> </span><span class="t">[</span><span class="nt">Pygments</span><span class="t">]</span><span class="t">(</span><span class="na">https://pygments.org/</span><span class="t">)</span><span class="t"> </span><span class="t">to</span><span class="t">
|
|
</span><span class="t">[</span><span class="nt">Crystal</span><span class="t">]</span><span class="t">(</span><span class="na">https://crystal-lang.org/</span><span class="t">)</span><span class="t">.</span><span class="t"> </span><span class="t">Kind</span><span class="t"> </span><span class="t">of.</span><span class="t">
|
|
</span><span class="t">
|
|
</span><span class="t">The</span><span class="t"> </span><span class="t">CLI</span><span class="t"> </span><span class="t">tool</span><span class="t"> </span><span class="t">can</span><span class="t"> </span><span class="t">be</span><span class="t"> </span><span class="t">used</span><span class="t"> </span><span class="t">to</span><span class="t"> </span><span class="t">highlight</span><span class="t"> </span><span class="t">many</span><span class="t"> </span><span class="t">things</span><span class="t"> </span><span class="t">in</span><span class="t"> </span><span class="t">many</span><span class="t"> </span><span class="t">styles.</span><span class="t">
|
|
</span><span class="t">
|
|
</span><span class="gh"># A port of what? Why "kind of"?</span><span class="t">
|
|
</span><span class="t"></span><span class="t">
|
|
</span><span class="t">Pygments</span><span class="t"> </span><span class="t">is</span><span class="t"> </span><span class="t">a</span><span class="t"> </span><span class="t">staple</span><span class="t"> </span><span class="t">of</span><span class="t"> </span><span class="t">the</span><span class="t"> </span><span class="t">Python</span><span class="t"> </span><span class="t">ecosystem,</span><span class="t"> </span><span class="t">and</span><span class="t"> </span><span class="t">it's</span><span class="t"> </span><span class="t">great.</span><span class="t">
|
|
</span><span class="t">It</span><span class="t"> </span><span class="t">lets</span><span class="t"> </span><span class="t">you</span><span class="t"> </span><span class="t">highlight</span><span class="t"> </span><span class="t">code</span><span class="t"> </span><span class="t">in</span><span class="t"> </span><span class="t">many</span><span class="t"> </span><span class="t">languages,</span><span class="t"> </span><span class="t">and</span><span class="t"> </span><span class="t">it</span><span class="t"> </span><span class="t">has</span><span class="t"> </span><span class="t">many</span><span class="t">
|
|
</span><span class="t">themes.</span><span class="t"> </span><span class="t">Chroma</span><span class="t"> </span><span class="t">is</span><span class="t"> </span><span class="t">"Pygments</span><span class="t"> </span><span class="t">for</span><span class="t"> </span><span class="t">Go",</span><span class="t"> </span><span class="t">it's</span><span class="t"> </span><span class="t">actually</span><span class="t"> </span><span class="t">a</span><span class="t"> </span><span class="t">port</span><span class="t"> </span><span class="t">of</span><span class="t">
|
|
</span><span class="t">Pygments</span><span class="t"> </span><span class="t">to</span><span class="t"> </span><span class="t">Go,</span><span class="t"> </span><span class="t">and</span><span class="t"> </span><span class="t">it's</span><span class="t"> </span><span class="t">great</span><span class="t"> </span><span class="t">too.</span><span class="t">
|
|
</span><span class="t">
|
|
</span><span class="t">I</span><span class="t"> </span><span class="t">wanted</span><span class="t"> </span><span class="t">that</span><span class="t"> </span><span class="t">in</span><span class="t"> </span><span class="t">Crystal,</span><span class="t"> </span><span class="t">so</span><span class="t"> </span><span class="t">I</span><span class="t"> </span><span class="t">started</span><span class="t"> </span><span class="t">this</span><span class="t"> </span><span class="t">project.</span><span class="t"> </span><span class="t">But</span><span class="t"> </span><span class="t">I</span><span class="t"> </span><span class="t">did</span><span class="t">
|
|
</span><span class="t">not</span><span class="t"> </span><span class="t">read</span><span class="t"> </span><span class="t">much</span><span class="t"> </span><span class="t">of</span><span class="t"> </span><span class="t">the</span><span class="t"> </span><span class="t">Pygments</span><span class="t"> </span><span class="t">code.</span><span class="t"> </span><span class="t">Or</span><span class="t"> </span><span class="t">much</span><span class="t"> </span><span class="t">of</span><span class="t"> </span><span class="t">Chroma's.</span><span class="t">
|
|
</span><span class="t">
|
|
</span><span class="t">Chroma</span><span class="t"> </span><span class="t">has</span><span class="t"> </span><span class="t">taken</span><span class="t"> </span><span class="t">most</span><span class="t"> </span><span class="t">of</span><span class="t"> </span><span class="t">the</span><span class="t"> </span><span class="t">Pygments</span><span class="t"> </span><span class="t">lexers</span><span class="t"> </span><span class="t">and</span><span class="t"> </span><span class="t">turned</span><span class="t"> </span><span class="t">them</span><span class="t"> </span><span class="t">into</span><span class="t">
|
|
</span><span class="t">XML</span><span class="t"> </span><span class="t">descriptions.</span><span class="t"> </span><span class="t">What</span><span class="t"> </span><span class="t">I</span><span class="t"> </span><span class="t">did</span><span class="t"> </span><span class="t">was</span><span class="t"> </span><span class="t">take</span><span class="t"> </span><span class="t">those</span><span class="t"> </span><span class="t">XML</span><span class="t"> </span><span class="t">files</span><span class="t"> </span><span class="t">from</span><span class="t"> </span><span class="t">Chroma</span><span class="t">
|
|
</span><span class="t">and</span><span class="t"> </span><span class="t">a</span><span class="t"> </span><span class="t">pile</span><span class="t"> </span><span class="t">of</span><span class="t"> </span><span class="t">test</span><span class="t"> </span><span class="t">cases</span><span class="t"> </span><span class="t">from</span><span class="t"> </span><span class="t">Pygments,</span><span class="t"> </span><span class="t">and</span><span class="t"> </span><span class="t">I</span><span class="t"> </span><span class="t">slapped</span><span class="t"> </span><span class="t">them</span><span class="t"> </span><span class="t">together</span><span class="t">
|
|
</span><span class="t">until</span><span class="t"> </span><span class="t">the</span><span class="t"> </span><span class="t">tests</span><span class="t"> </span><span class="t">passed</span><span class="t"> </span><span class="t">and</span><span class="t"> </span><span class="t">my</span><span class="t"> </span><span class="t">code</span><span class="t"> </span><span class="t">produced</span><span class="t"> </span><span class="t">the</span><span class="t"> </span><span class="t">same</span><span class="t"> </span><span class="t">output</span><span class="t"> </span><span class="t">as</span><span class="t">
|
|
</span><span class="t">Chroma.</span><span class="t"> </span><span class="t">Think</span><span class="t"> </span><span class="t">of</span><span class="t"> </span><span class="t">it</span><span class="t"> </span><span class="t">as</span><span class="t"> </span><span class="ge">*extreme TDD*</span><span class="t">.</span><span class="t">
|
|
</span><span class="t">
|
|
</span><span class="t">Currently</span><span class="t"> </span><span class="t">the</span><span class="t"> </span><span class="t">pass</span><span class="t"> </span><span class="t">rate</span><span class="t"> </span><span class="t">for</span><span class="t"> </span><span class="t">tests</span><span class="t"> </span><span class="t">in</span><span class="t"> </span><span class="t">the</span><span class="t"> </span><span class="t">supported</span><span class="t"> </span><span class="t">languages</span><span class="t">
|
|
</span><span class="t">is</span><span class="t"> </span><span class="lsb">`96.8%`</span><span class="t">,</span><span class="t"> </span><span class="t">which</span><span class="t"> </span><span class="t">is</span><span class="t"> </span><span class="ge">*not bad for a couple days hacking*</span><span class="t">.</span><span class="t">
|
|
</span><span class="t">
|
|
</span><span class="t">This</span><span class="t"> </span><span class="t">only</span><span class="t"> </span><span class="t">covers</span><span class="t"> </span><span class="t">the</span><span class="t"> </span><span class="t">RegexLexers,</span><span class="t"> </span><span class="t">which</span><span class="t"> </span><span class="t">are</span><span class="t"> </span><span class="t">the</span><span class="t"> </span><span class="t">most</span><span class="t"> </span><span class="t">common</span><span class="t"> </span><span class="t">ones,</span><span class="t">
|
|
</span><span class="t">but</span><span class="t"> </span><span class="t">it</span><span class="t"> </span><span class="t">means</span><span class="t"> </span><span class="t">the</span><span class="t"> </span><span class="t">supported</span><span class="t"> </span><span class="t">languages</span><span class="t"> </span><span class="t">are</span><span class="t"> </span><span class="t">a</span><span class="t"> </span><span class="t">subset</span><span class="t"> </span><span class="t">of</span><span class="t"> </span><span class="t">Chroma's,</span><span class="t"> </span><span class="t">which</span><span class="t">
|
|
</span><span class="t">is</span><span class="t"> </span><span class="t">a</span><span class="t"> </span><span class="t">subset</span><span class="t"> </span><span class="t">of</span><span class="t"> </span><span class="t">Pygments'.</span><span class="t">
|
|
</span><span class="t">
|
|
</span><span class="t">Currently</span><span class="t"> </span><span class="t">Tartrazine</span><span class="t"> </span><span class="t">supports</span><span class="t"> </span><span class="t">...</span><span class="t"> </span><span class="t">241</span><span class="t"> </span><span class="t">languages.</span><span class="t">
|
|
</span><span class="t">
|
|
</span><span class="t">It</span><span class="t"> </span><span class="t">has</span><span class="t"> </span><span class="t">331</span><span class="t"> </span><span class="t">themes</span><span class="t"> </span><span class="t">(63</span><span class="t"> </span><span class="t">from</span><span class="t"> </span><span class="t">Chroma,</span><span class="t"> </span><span class="t">the</span><span class="t"> </span><span class="t">rest</span><span class="t"> </span><span class="t">are</span><span class="t"> </span><span class="t">base16</span><span class="t"> </span><span class="t">themes</span><span class="t"> </span><span class="t">via</span><span class="t">
|
|
</span><span class="t">[</span><span class="nt">Sixteen</span><span class="t">]</span><span class="t">(</span><span class="na">https://github.com/ralsina/sixteen</span><span class="t">)</span><span class="t">
|
|
</span><span class="t">
|
|
</span><span class="gs">## Installation</span><span class="t">
|
|
</span><span class="t"></span><span class="t">
|
|
</span><span class="t">From</span><span class="t"> </span><span class="t">prebuilt</span><span class="t"> </span><span class="t">binaries:</span><span class="t">
|
|
</span><span class="t">
|
|
</span><span class="t">Each</span><span class="t"> </span><span class="t">release</span><span class="t"> </span><span class="t">provides</span><span class="t"> </span><span class="t">statically-linked</span><span class="t"> </span><span class="t">binaries</span><span class="t"> </span><span class="t">that</span><span class="t"> </span><span class="t">should</span><span class="t">
|
|
</span><span class="t">work</span><span class="t"> </span><span class="t">on</span><span class="t"> </span><span class="t">any</span><span class="t"> </span><span class="t">Linux.</span><span class="t"> </span><span class="t">Get</span><span class="t"> </span><span class="t">them</span><span class="t"> </span><span class="t">from</span><span class="t"> </span><span class="t">the</span><span class="t"> </span><span class="t">[</span><span class="nt">releases page</span><span class="t">]</span><span class="t">(</span><span class="na">https://github.com/ralsina/tartrazine/releases</span><span class="t">)</span><span class="t"> </span><span class="t">and</span><span class="t"> </span><span class="t">put</span><span class="t"> </span><span class="t">them</span><span class="t"> </span><span class="t">in</span><span class="t"> </span><span class="t">your</span><span class="t"> </span><span class="t">PATH.</span><span class="t">
|
|
</span><span class="t">
|
|
</span><span class="t">To</span><span class="t"> </span><span class="t">build</span><span class="t"> </span><span class="t">from</span><span class="t"> </span><span class="t">source:</span><span class="t">
|
|
</span><span class="tw">
|
|
</span><span class="tw"></span><span class="k">1.</span><span class="t"> </span><span class="t">Clone</span><span class="t"> </span><span class="t">this</span><span class="t"> </span><span class="t">repo</span><span class="t">
|
|
</span><span class="t"></span><span class="k">2.</span><span class="t"> </span><span class="t">Run</span><span class="t"> </span><span class="lsb">`make`</span><span class="t"> </span><span class="t">to</span><span class="t"> </span><span class="t">build</span><span class="t"> </span><span class="t">the</span><span class="t"> </span><span class="lsb">`tartrazine`</span><span class="t"> </span><span class="t">binary</span><span class="t">
|
|
</span><span class="t"></span><span class="k">3.</span><span class="t"> </span><span class="t">Copy</span><span class="t"> </span><span class="t">the</span><span class="t"> </span><span class="t">binary</span><span class="t"> </span><span class="t">somewhere</span><span class="t"> </span><span class="t">in</span><span class="t"> </span><span class="t">your</span><span class="t"> </span><span class="t">PATH.</span><span class="t">
|
|
</span><span class="t"></span><span class="t">
|
|
</span><span class="gs">## Usage as a CLI tool</span><span class="t">
|
|
</span><span class="t"></span><span class="t">
|
|
</span><span class="t">```shell
|
|
</span><span class="t">$ tartrazine whatever.c -l c -t catppuccin-macchiato --line-numbers \
|
|
</span><span class="t"> --standalone -o whatever.html
|
|
</span><span class="t">```
|
|
</span><span class="t"></span><span class="t">
|
|
</span><span class="gs">## Usage as a Library</span><span class="t">
|
|
</span><span class="t"></span><span class="t">
|
|
</span><span class="t">This</span><span class="t"> </span><span class="t">works:</span><span class="t">
|
|
</span><span class="t">
|
|
</span><span class="t">```crystal
|
|
</span><span class="t">require "tartrazine"
|
|
</span><span class="t">
|
|
</span><span class="t">lexer = Tartrazine.lexer("crystal")
|
|
</span><span class="t">theme = Tartrazine.theme("catppuccin-macchiato")
|
|
</span><span class="t">formatter = Tartrazine::Html.new
|
|
</span><span class="t">formatter.theme = theme
|
|
</span><span class="t">puts formatter.format(File.read(ARGV[0]), lexer)
|
|
</span><span class="t">```
|
|
</span><span class="t"></span><span class="t">
|
|
</span><span class="gs">## Contributing</span><span class="t">
|
|
</span><span class="t"></span><span class="tw">
|
|
</span><span class="tw"></span><span class="k">1.</span><span class="t"> </span><span class="t">Fork</span><span class="t"> </span><span class="t">it</span><span class="t"> </span><span class="t">(<https://github.com/ralsina/tartrazine/fork>)</span><span class="t">
|
|
</span><span class="t"></span><span class="k">2.</span><span class="t"> </span><span class="t">Create</span><span class="t"> </span><span class="t">your</span><span class="t"> </span><span class="t">feature</span><span class="t"> </span><span class="t">branch</span><span class="t"> </span><span class="t">(</span><span class="lsb">`git checkout -b my-new-feature`</span><span class="t">)</span><span class="t">
|
|
</span><span class="t"></span><span class="k">3.</span><span class="t"> </span><span class="t">Commit</span><span class="t"> </span><span class="t">your</span><span class="t"> </span><span class="t">changes</span><span class="t"> </span><span class="t">(</span><span class="lsb">`git commit -am 'Add some feature'`</span><span class="t">)</span><span class="t">
|
|
</span><span class="t"></span><span class="k">4.</span><span class="t"> </span><span class="t">Push</span><span class="t"> </span><span class="t">to</span><span class="t"> </span><span class="t">the</span><span class="t"> </span><span class="t">branch</span><span class="t"> </span><span class="t">(</span><span class="lsb">`git push origin my-new-feature`</span><span class="t">)</span><span class="t">
|
|
</span><span class="t"></span><span class="k">5.</span><span class="t"> </span><span class="t">Create</span><span class="t"> </span><span class="t">a</span><span class="t"> </span><span class="t">new</span><span class="t"> </span><span class="t">Pull</span><span class="t"> </span><span class="t">Request</span><span class="t">
|
|
</span><span class="t"></span><span class="t">
|
|
</span><span class="gs">## Contributors</span><span class="t">
|
|
</span><span class="t"></span><span class="tw">
|
|
</span><span class="tw"></span><span class="k">-</span><span class="tw"> </span><span class="t">[</span><span class="nt">Roberto Alsina</span><span class="t">]</span><span class="t">(</span><span class="na">https://github.com/ralsina</span><span class="t">)</span><span class="t"> </span><span class="t">-</span><span class="t"> </span><span class="t">creator</span><span class="t"> </span><span class="t">and</span><span class="t"> </span><span class="t">maintainer</span><span class="t">
|
|
</span><span class="t"></span></code></pre></body></html> |