chore: pre-commit hooks

This commit is contained in:
Roberto Alsina 2024-08-26 20:18:28 -03:00
parent c6824a99df
commit fb693bb221
289 changed files with 339 additions and 309 deletions

27
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,27 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-merge-conflict
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: shellcheck
- id: markdownlint
exclude: '^content'
- repo: https://github.com/mrtazz/checkmake
rev: 0.2.2
hooks:
- id: checkmake
exclude: lexers/makefile.xml
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.23.2
hooks:
- id: check-github-workflows

View File

@ -1,3 +1,5 @@
all: build
build: $(wildcard src/**/*.cr) $(wildcard lexers/*xml) $(wildcard styles/*xml) shard.yml
shards build -Dstrict_multi_assign -Dno_number_autocast -d --error-trace
release: $(wildcard src/**/*.cr) $(wildcard lexers/*xml) $(wildcard styles/*xml) shard.yml
@ -5,3 +7,15 @@ release: $(wildcard src/**/*.cr) $(wildcard lexers/*xml) $(wildcard styles/*xml)
static: $(wildcard src/**/*.cr) $(wildcard lexers/*xml) $(wildcard styles/*xml) shard.yml
shards build --release --static
strip bin/tartrazine
clean:
rm -rf bin lib shard.lock
test:
crystal spec
lint:
ameba --fix src spec
.PHONY: clean all test bin lint

View File

@ -6,15 +6,16 @@ a port of [Pygments](https://pygments.org/) to
It also provides a CLI tool which can be used to highlight many things in many styles.
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)
Currently Tartrazine supports 247 languages and has 331 themes (63 from Chroma,
the rest are base16 themes via [Sixteen](https://github.com/ralsina/sixteen)
## Installation
From prebuilt binaries:
Each release provides statically-linked binaries that should
work on any Linux. Get them from the [releases page](https://github.com/ralsina/tartrazine/releases) and put them in your PATH.
work on any Linux. Get them from the [releases page](https://github.com/ralsina/tartrazine/releases)
and put them in your PATH.
To build from source:
@ -27,14 +28,14 @@ To build from source:
Show a syntax highlighted version of a C source file in your terminal:
```shell
$ tartrazine whatever.c -l c -t catppuccin-macchiato --line-numbers -f terminal
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 -t catppuccin-macchiato --line-numbers \
--standalone -f html -o whatever.html
--standalone -f html -o whatever.html
```
## Usage as a Library
@ -63,7 +64,7 @@ puts formatter.format(File.read(ARGV[0]), lexer)
- [Roberto Alsina](https://github.com/ralsina) - creator and maintainer
## A port of what? Why "kind of"?
## A port of what, and 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
@ -86,5 +87,6 @@ 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.
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.

View File

@ -127,4 +127,3 @@
</state>
</rules>
</lexer>

View File

@ -52,4 +52,3 @@
</state>
</rules>
</lexer>

View File

@ -151,4 +151,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -63,4 +63,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -65,4 +65,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -160,4 +160,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -318,4 +318,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -63,4 +63,3 @@
</state>
</rules>
</lexer>

View File

@ -72,4 +72,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -55,4 +55,3 @@
</state>
</rules>
</lexer>

View File

@ -105,4 +105,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -314,4 +314,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -71,4 +71,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -56,4 +56,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -127,4 +127,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -171,4 +171,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -306,4 +306,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -123,4 +123,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -75,4 +75,3 @@
</state>
</rules>
</lexer>

View File

@ -67,4 +67,3 @@
</state>
</rules>
</lexer>

View File

@ -92,4 +92,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -94,4 +94,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -217,4 +217,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -22,4 +22,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -657,4 +657,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -19,4 +19,3 @@
</state>
</rules>
</lexer>

View File

@ -149,4 +149,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -81,4 +81,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -138,4 +138,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -25,4 +25,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -80,4 +80,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -48,4 +48,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -118,4 +118,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -328,4 +328,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -119,4 +119,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -134,4 +134,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -148,4 +148,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -89,4 +89,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -131,4 +131,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -140,4 +140,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -52,4 +52,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -87,4 +87,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -87,4 +87,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -207,4 +207,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -181,4 +181,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -133,4 +133,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -759,4 +759,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -320,4 +320,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -369,4 +369,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -130,4 +130,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -210,4 +210,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -14,4 +14,4 @@
<rule pattern="([-A-Za-z0-9]+)(\[[^\] \t=]+\])?([ \t]*)(=)([ \t]*)([^\n]*)([ \t\n]*\n)"><bygroups><token type="NameAttribute"/><token type="NameNamespace"/><token type="TextWhitespace"/><token type="Operator"/><token type="TextWhitespace"/><token type="LiteralString"/><token type="TextWhitespace"/></bygroups></rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -49,4 +49,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -150,4 +150,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -54,4 +54,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -165,4 +165,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -173,4 +173,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -87,4 +87,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -741,4 +741,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -116,4 +116,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -129,4 +129,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -163,4 +163,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -409,4 +409,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -65,4 +65,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -156,4 +156,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -75,4 +75,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -68,4 +68,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -260,4 +260,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -62,4 +62,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -286,4 +286,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -111,4 +111,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -85,4 +85,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -144,4 +144,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -269,4 +269,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -140,4 +140,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -186,4 +186,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -146,4 +146,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -156,4 +156,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -101,4 +101,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -213,4 +213,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -44,4 +44,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -42,4 +42,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -68,4 +68,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -154,4 +154,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -157,4 +157,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -108,4 +108,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -15,7 +15,7 @@
</rule>
<rule pattern="\.\."> // Spread operator
<token type="Operator"/>
</rule>
</rule>
<rule pattern="\^(?=\()"> // Sort operator
<token type="Operator"/>
</rule>
@ -54,7 +54,7 @@
</rule>
<rule pattern="(\+|-)?(0|[1-9]\d*)(\.\d+[eE](\+|-)?\d+|[eE](\+|-)?\d+|\.\d+)">
<token type="LiteralNumberFloat"/>
</rule>
</rule>
<rule pattern="(\+|-)?(0|[1-9]\d*)">
<token type="LiteralNumberInteger"/>
</rule>
@ -75,9 +75,9 @@
</rule>
<!-- NOTE: This expression matches everything remaining, which should be only JSONata names.
Therefore, it has been left as last intentionally -->
<rule pattern="[a-zA-Z0-9_]*">
<rule pattern="[a-zA-Z0-9_]*">
<token type="Name"/>
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -397,4 +397,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -95,4 +95,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -220,4 +220,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -39,4 +39,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -70,4 +70,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -155,4 +155,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -128,4 +128,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -117,4 +117,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

View File

@ -28,9 +28,9 @@
<rule pattern="^(```)(\w+)(\n)([\w\W]*?)(^```$)">
<bygroups>
<token type="LiteralStringBacktick"/>
<token type="NameLabel"/>
<token type="NameLabel"/>
<token type="TextWhitespace"/>
<UsingByGroup lexer="2" content="4"/>
<UsingByGroup lexer="2" content="4"/>
<token type="LiteralStringBacktick"/>
</bygroups>
</rule>
@ -53,4 +53,3 @@
</state>
</rules>
</lexer>

View File

@ -86,4 +86,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>

Some files were not shown because too many files have changed in this diff Show More