on master help sign in
Merge remote-tracking branch 'origin/master' into fix-1063
commit478233f7952d1c634258a76589d2f8151d7c51c0 authorMartin Nordholts <enselic@gmail.com> dateMon 4 Jan 2021, 21:02 (6 years ago) parente87c5548381945
24 files changed+629−54
.github/ISSUE_TEMPLATE/bug_report.md+23−15 .github/workflows/CICD.yml+1−1 .gitmodules+6 CHANGELOG.md+4 Cargo.lock+20−21 Cargo.toml+3−3 README.md+1−1 assets/syntaxes/02_Extra/Julia+1−1 assets/syntaxes/02_Extra/Lean+1 assets/syntaxes/02_Extra/Lean.sublime-syntax+125 assets/syntaxes/02_Extra/Robot.sublime-syntax+1 assets/syntaxes/02_Extra/SCSS_Sass+1−1 assets/syntaxes/02_Extra/TypeScript+1−1 assets/syntaxes/02_Extra/Zig+1 assets/themes/dracula-sublime+1−1 assets/themes/zenburn+1−1 doc/assets.md+39−3 tests/benchmarks/run-benchmarks.sh+48−4 tests/syntax-tests/highlighted/Lean/test.lean+68 tests/syntax-tests/highlighted/Zig/example.zig+107 tests/syntax-tests/source/DotENV/.env+1−1 tests/syntax-tests/source/Lean/test.lean+68 tests/syntax-tests/source/Svelte/LICENSE → tests/syntax-tests/source/Svelte/LICENSE.md tests/syntax-tests/source/Zig/example.zig+107
.github/ISSUE_TEMPLATE/bug_report.md+23−15
@@ -7,33 +7,41 @@ assignees: ''
77
88---
99
10−<!--
11−Hey there, thanks for creating an issue!
12−
13−In order to reproduce your issue, we might need to know a little bit more about the environment
14−which you're running `bat` on.
10+<!-- Hey there, thank you for creating an issue! -->
1511
16−If you're on Linux or MacOS:
17− Please run the script at https://github.com/sharkdp/bat/blob/master/diagnostics/info.sh and
18− paste the output at the bottom of the bug report.
12+**What version of `bat` are you using?**
1913
20−If you're on Windows:
21− Please tell us about your Windows Version (e.g. "Windows 10 1908") at the
22− bottom of the bug report.
23−-->
14+<!-- Output of `bat --version` -->
2415
25−**What version of `bat` are you using?**
26−[paste the output of `bat --version` here]
2716
2817**Describe the bug you encountered:**
18+
2919...
3020
3121**What did you expect to happen instead?**
22+
3223...
3324
25+
3426**How did you install `bat`?**
27+
3528<!-- apt-get, homebrew, GitHub release, etc. -->
3629
3730---
3831
39−[paste the output of `info.sh` here]
32+**Evironment**
33+
34+<!--
35+In order to reproduce your issue, please add some information about the environment
36+in which you're running bat.
37+
38+Linux and MacOS:
39+ Please run the script at
40+
41+ https://github.com/sharkdp/bat/blob/master/diagnostics/info.sh
42+
43+ (click "Raw" to get the actual source code) and paste the Markdown output here.
44+
45+Windows:
46+ Please add your Windows Version (e.g. "Windows 10 1908")
47+-->
.github/workflows/CICD.yml+1−1
@@ -27,7 +27,7 @@ jobs:
2727 uses: actions-rs/cargo@v1
2828 with:
2929 command: clippy
30− args: --all-targets --all-features
30+ args: --all-targets --all-features -- --allow clippy::style
3131 - name: Test
3232 uses: actions-rs/cargo@v1
3333 with:
.gitmodules+6
@@ -207,3 +207,9 @@
207207 path = assets/themes/gruvbox
208208 url = https://github.com/subnut/gruvbox-tmTheme.git
209209 branch = bat-source
210+[submodule "assets/syntaxes/02_Extra/Lean"]
211+ path = assets/syntaxes/02_Extra/Lean
212+ url = https://github.com/leanprover/vscode-lean.git
213+[submodule "assets/syntaxes/02_Extra/Zig"]
214+ path = assets/syntaxes/02_Extra/Zig
215+ url = https://github.com/ziglang/sublime-zig-language.git
CHANGELOG.md+4
@@ -19,6 +19,10 @@
1919
2020## Syntaxes
2121
22+- Added Zig syntax, see #1470 (@paulsmith)
23+- Added Lean syntax, see #1446 (@Julian)
24+- Added `.resource` extension for Robot Framework files, see #1386
25+
2226## New themes
2327
2428- `ansi` replaces `ansi-dark` and `ansi-light`, see #1104 and #1412 (@mk12)
Cargo.lock+20−21
@@ -253,9 +253,9 @@ dependencies = [
253253
254254[[package]]
255255name = "console"
256−version = "0.13.0"
256+version = "0.14.0"
257257source = "registry+https://github.com/rust-lang/crates.io-index"
258−checksum = "a50aab2529019abfabfa93f1e6c41ef392f91fbf179b347a7e96abb524884a08"
258+checksum = "7cc80946b3480f421c2f17ed1cb841753a371c7c5104f51d507e13f532c856aa"
259259dependencies = [
260260 "encode_unicode",
261261 "lazy_static",
@@ -264,7 +264,6 @@ dependencies = [
264264 "terminal_size",
265265 "unicode-width",
266266 "winapi",
267− "winapi-util",
268267]
269268
270269[[package]]
@@ -499,9 +498,9 @@ dependencies = [
499498
500499[[package]]
501500name = "git2"
502−version = "0.13.12"
501+version = "0.13.15"
503502source = "registry+https://github.com/rust-lang/crates.io-index"
504−checksum = "ca6f1a0238d7f8f8fd5ee642f4ebac4dbc03e03d1f78fbe7a3ede35dcf7e2224"
503+checksum = "44f267c9da8a4de3c615b59e23606c75f164f84896e97f4dd6c15a4294de4359"
505504dependencies = [
506505 "bitflags",
507506 "libc",
@@ -609,9 +608,9 @@ checksum = "aa7087f49d294270db4e1928fc110c976cd4b9e5a16348e0a1df09afa99e6c98"
609608
610609[[package]]
611610name = "libgit2-sys"
612−version = "0.12.14+1.1.0"
611+version = "0.12.17+1.1.0"
613612source = "registry+https://github.com/rust-lang/crates.io-index"
614−checksum = "8f25af58e6495f7caf2919d08f212de550cfa3ed2f5e744988938ea292b9f549"
613+checksum = "f4ebdf65ca745126df8824688637aa0535a88900b83362d8ca63893bcf4e8841"
615614dependencies = [
616615 "cc",
617616 "libc",
@@ -850,9 +849,9 @@ dependencies = [
850849
851850[[package]]
852851name = "predicates"
853−version = "1.0.5"
852+version = "1.0.6"
854853source = "registry+https://github.com/rust-lang/crates.io-index"
855−checksum = "96bfead12e90dccead362d62bb2c90a5f6fc4584963645bc7f71a735e0b0735a"
854+checksum = "73dd9b7b200044694dfede9edf907c1ca19630908443e9447e624993700c6932"
856855dependencies = [
857856 "difference",
858857 "float-cmp",
@@ -951,9 +950,9 @@ dependencies = [
951950
952951[[package]]
953952name = "regex"
954−version = "1.3.9"
953+version = "1.4.2"
955954source = "registry+https://github.com/rust-lang/crates.io-index"
956−checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
955+checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c"
957956dependencies = [
958957 "aho-corasick",
959958 "memchr",
@@ -963,9 +962,9 @@ dependencies = [
963962
964963[[package]]
965964name = "regex-syntax"
966−version = "0.6.18"
965+version = "0.6.21"
967966source = "registry+https://github.com/rust-lang/crates.io-index"
968−checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
967+checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189"
969968
970969[[package]]
971970name = "remove_dir_all"
@@ -1036,18 +1035,18 @@ dependencies = [
10361035
10371036[[package]]
10381037name = "serde"
1039−version = "1.0.117"
1038+version = "1.0.118"
10401039source = "registry+https://github.com/rust-lang/crates.io-index"
1041−checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a"
1040+checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800"
10421041dependencies = [
10431042 "serde_derive",
10441043]
10451044
10461045[[package]]
10471046name = "serde_derive"
1048−version = "1.0.117"
1047+version = "1.0.118"
10491048source = "registry+https://github.com/rust-lang/crates.io-index"
1050−checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e"
1049+checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df"
10511050dependencies = [
10521051 "proc-macro2",
10531052 "quote",
@@ -1148,9 +1147,9 @@ dependencies = [
11481147
11491148[[package]]
11501149name = "syntect"
1151−version = "4.4.0"
1150+version = "4.5.0"
11521151source = "registry+https://github.com/rust-lang/crates.io-index"
1153−checksum = "4e3978df05b5850c839a6b352d3c35ce0478944a4be689be826b53cf75363e88"
1152+checksum = "2bfac2b23b4d049dc9a89353b4e06bbc85a8f42020cccbe5409a115cf19031e5"
11541153dependencies = [
11551154 "bincode",
11561155 "bitflags",
@@ -1191,9 +1190,9 @@ dependencies = [
11911190
11921191[[package]]
11931192name = "terminal_size"
1194−version = "0.1.13"
1193+version = "0.1.15"
11951194source = "registry+https://github.com/rust-lang/crates.io-index"
1196−checksum = "9a14cd9f8c72704232f0bfc8455c0e861f0ad4eb60cc9ec8a170e231414c1e13"
1195+checksum = "4bd2d183bd3fac5f5fe38ddbeb4dc9aec4a39a9d7d59e7491d900302da01cbe1"
11971196dependencies = [
11981197 "libc",
11991198 "winapi",
Cargo.toml+3−3
@@ -37,7 +37,7 @@ regex-fancy = ["syntect/regex-fancy"] # Use the rust-only "fancy-regex" engine
3737atty = { version = "0.2.14", optional = true }
3838ansi_term = "^0.12.1"
3939ansi_colours = "^1.0"
40−console = "0.13.0"
40+console = "0.14.0"
4141dirs = { version = "3.0", optional = true }
4242lazy_static = { version = "1.4", optional = true }
4343wild = { version = "2.0", optional = true }
@@ -57,7 +57,7 @@ optional = true
5757default-features = false
5858
5959[dependencies.syntect]
60−version = "4.4.0"
60+version = "4.5.0"
6161default-features = false
6262features = ["parsing", "yaml-load", "dump-load", "dump-create"]
6363
@@ -75,7 +75,7 @@ default-features = false
7575tempdir = "0.3"
7676assert_cmd = "1.0.2"
7777serial_test = "0.5.1"
78−predicates = "1.0.5"
78+predicates = "1.0.6"
7979
8080[build-dependencies]
8181clap = { version = "2.33", optional = true }
README.md+1−1
@@ -180,7 +180,7 @@ The [`prettybat`](https://github.com/eth-p/bat-extras/blob/master/doc/prettybat.
180180
181181## Installation
182182
183−[![Packaging status](https://repology.org/badge/vertical-allrepos/bat.svg)](https://repology.org/project/bat/versions)
183+[![Packaging status](https://repology.org/badge/vertical-allrepos/bat-cat.svg)](https://repology.org/project/bat-cat/versions)
184184
185185### On Ubuntu (using `apt`)
186186*... and other Debian-based Linux distributions.*
assets/syntaxes/02_Extra/Julia+1−1

Submodule changed.

assets/syntaxes/02_Extra/Leannew file+1

Submodule changed.

assets/syntaxes/02_Extra/Lean.sublime-syntaxnew file+125
@@ -0,0 +1,125 @@
1+%YAML 1.2
2+---
3+# http://www.sublimetext.com/docs/3/syntax.html
4+name: Lean
5+file_extensions:
6+ - lean
7+scope: source.lean
8+contexts:
9+ main:
10+ - include: comments
11+ - match: '\b(?<!\.)(inductive|coinductive|structure|theorem|axiom|axioms|abbreviation|lemma|definition|def|instance|class|constant)\b\s+(\{[^}]*\})?'
12+ captures:
13+ 1: keyword.other.definitioncommand.lean
14+ push:
15+ - meta_scope: meta.definitioncommand.lean
16+ - match: '(?=\bwith\b|\bextends\b|[:\|\(\[\{⦃<>])'
17+ pop: true
18+ - include: comments
19+ - include: definitionName
20+ - match: ","
21+ - match: \b(Prop|Type|Sort)\b
22+ scope: storage.type.lean
23+ - match: '\battribute\b\s*\[[^\]]*\]'
24+ scope: storage.modifier.lean
25+ - match: '@\[[^\]]*\]'
26+ scope: storage.modifier.lean
27+ - match: \b(?<!\.)(private|meta|mutual|protected|noncomputable)\b
28+ scope: keyword.control.definition.modifier.lean
29+ - match: \b(sorry)\b
30+ scope: invalid.illegal.lean
31+ - match: '#print\s+(def|definition|inductive|instance|structure|axiom|axioms|class)\b'
32+ scope: keyword.other.command.lean
33+ - match: '#(print|eval|reduce|check|help|exit|find|where)\b'
34+ scope: keyword.other.command.lean
35+ - match: \b(?<!\.)(import|export|prelude|theory|definition|def|abbreviation|instance|renaming|hiding|exposing|parameter|parameters|begin|constant|constants|lemma|variable|variables|theorem|example|open|axiom|inductive|coinductive|with|structure|universe|universes|alias|precedence|reserve|postfix|prefix|infix|infixl|infixr|notation|end|using|namespace|section|local|set_option|extends|include|omit|class|classes|instances|raw|run_cmd|restate_axiom)(?!\.)\b
36+ scope: keyword.other.lean
37+ - match: \b(?<!\.)(calc|have|this|match|do|suffices|show|by|in|at|let|forall|fun|exists|assume|from|obtain|haveI|λ)(?!\.)\b
38+ scope: keyword.other.lean
39+ - match: «
40+ push:
41+ - meta_content_scope: entity.name.lean
42+ - match: »
43+ pop: true
44+ - match: \b(?<!\.)(if|then|else)\b
45+ scope: keyword.control.lean
46+ - match: '"'
47+ captures:
48+ 0: punctuation.definition.string.begin.lean
49+ push:
50+ - meta_scope: string.quoted.double.lean
51+ - match: '"'
52+ captures:
53+ 0: punctuation.definition.string.end.lean
54+ pop: true
55+ - match: '\\[\\"nt'']'
56+ scope: constant.character.escape.lean
57+ - match: '\\x[0-9A-Fa-f][0-9A-Fa-f]'
58+ scope: constant.character.escape.lean
59+ - match: '\\u[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]'
60+ scope: constant.character.escape.lean
61+ - match: '''[^\\'']'''
62+ scope: string.quoted.single.lean
63+ - match: '''(\\(x..|u....|.))'''
64+ scope: string.quoted.single.lean
65+ captures:
66+ 1: constant.character.escape.lean
67+ - match: '`+[^\[(]\S+'
68+ scope: entity.name.lean
69+ - match: '\b([0-9]+|0([xX][0-9a-fA-F]+))\b'
70+ scope: constant.numeric.lean
71+ blockComment:
72+ - match: /-
73+ push:
74+ - meta_scope: comment.block.lean
75+ - match: "-/"
76+ pop: true
77+ - include: scope:source.lean.markdown
78+ - include: blockComment
79+ comments:
80+ - include: dashComment
81+ - include: docComment
82+ - include: stringBlock
83+ - include: modDocComment
84+ - include: blockComment
85+ dashComment:
86+ - match: (--)
87+ captures:
88+ 0: punctuation.definition.comment.lean
89+ push:
90+ - meta_scope: comment.line.double-dash.lean
91+ - match: $
92+ pop: true
93+ - include: scope:source.lean.markdown
94+ definitionName:
95+ - match: '\b[^:«»\(\)\{\}[:space:]=→λ∀?][^:«»\(\)\{\}[:space:]]*'
96+ scope: entity.name.function.lean
97+ - match: «
98+ push:
99+ - meta_content_scope: entity.name.function.lean
100+ - match: »
101+ pop: true
102+ docComment:
103+ - match: /--
104+ push:
105+ - meta_scope: comment.block.documentation.lean
106+ - match: "-/"
107+ pop: true
108+ - include: scope:source.lean.markdown
109+ - include: blockComment
110+ modDocComment:
111+ - match: /-!
112+ push:
113+ - meta_scope: comment.block.documentation.lean
114+ - match: "-/"
115+ pop: true
116+ - include: scope:source.lean.markdown
117+ - include: blockComment
118+ stringBlock:
119+ - match: /-"
120+ push:
121+ - meta_scope: comment.block.string.lean
122+ - match: '"-/'
123+ pop: true
124+ - include: scope:source.lean.markdown
125+ - include: blockComment
assets/syntaxes/02_Extra/Robot.sublime-syntax+1
@@ -4,6 +4,7 @@
44name: Robot Framework
55file_extensions:
66 - robot
7+ - resource
78scope: source.robot
89contexts:
910 main:
assets/syntaxes/02_Extra/SCSS_Sass+1−1

Submodule changed.

assets/syntaxes/02_Extra/TypeScript+1−1

Submodule changed.

assets/syntaxes/02_Extra/Zignew file+1

Submodule changed.

assets/themes/dracula-sublime+1−1

Submodule changed.

assets/themes/zenburn+1−1

Submodule changed.

doc/assets.md+39−3
@@ -16,16 +16,51 @@ in the `.sublime-syntax` format.
1616 *New Syntax from XXX.tmLanguage...*. Save the new file in the `assets/syntaxes` folder.
1717
18183. Run the `assets/create.sh` script. It calls `bat cache --build` to parse all available
19− `.sublime-syntax` files and serialize them to a `syntaxes.bin` file (in this folder).
19+ `.sublime-syntax` files and serialize them to a `syntaxes.bin` file.
2020
21214. Re-compile `bat`. At compilation time, the `syntaxes.bin` file will be stored inside the
2222 `bat` binary.
2323
24245. Use `bat --list-languages` to check if the new languages are available.
2525
26−6. If you send a pull request with your changes, please do *not* include the changed `syntaxes.bin`
26+6. Add a syntax test for the new language. See [#Syntax-tests](below) for details.
27+
28+7. If you send a pull request with your changes, please do *not* include the changed `syntaxes.bin`
2729 file. A new binary cache file will be created once before every new release of `bat`.
2830
31+### Syntax tests
32+
33+`bat` has a set of syntax highlighting regression tests in `tests/syntax-tests`. The main idea is
34+make sure that we do not run into issues we had in the past where either (1) syntax highlighting
35+for some language is suddenly not working anymore or (2) `bat` suddenly crashes for some input (due
36+to `regex` incompatibilities between `syntect` and Sublime Text).
37+
38+In order to add a new test file, please follow these steps (let's take "Ruby" as an example):
39+
40+1. Make sure that you are running the **latest version of `bat`** and that `bat` is available on
41+ the path. If you are creating a syntax test for a new builtin syntax (see above), make sure that
42+ your version of `bat` already has the new syntax builtin.
43+2. Find an example Ruby source file or write one yourself. If possible, the file should aim to be
44+ "comprehensive" (i.e. include a lot of the possible syntax), but this is not strictly necessary.
45+ A simple file is better than none at all. Also, the files shouldn't be gigantic.
46+3. Save the file in `tests/syntax-tests/source/Ruby` (adapt for your language). The file name could
47+ be `test.rb` (adapt extension) but can also be adapted if that is necessary in order for `bat` to
48+ highlight it correctly (e.g. `Makefile`).
49+4. If you have copied the file from somewhere else, please make sure that the file *may* be copied
50+ under the respective license and that the license is compatible with `bat`s license. If it
51+ requires attribution, please add a `LICENSE.md` in the same folder with a text like this:
52+ ```
53+ The `test.rb` file has been added from [enter source here] under the following license:
54+
55+ [add license text here]
56+ ```
57+5. Go to `tests/syntax-tests` and run the `update.sh` Bash script. A new file should be generated
58+ in the `highlighted` folder (e.g. `highlighted/Ruby/test.rb`).
59+6. Use `cat` or `bat --language=txt` to display the content of this file and make sure that the
60+ syntax highlighting looks correct.
61+7. `git add` the new files in the `source` folder as well as the autogenerated files in the
62+ `highlighted` folder.
63+
2964### Troubleshooting
3065
3166Make sure that the local cache does not interfere with the internally stored syntaxes and
@@ -44,7 +79,7 @@ The following files have been manually modified after converting from a `.tmLang
4479* `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types and support for comments after section headers
4580* `Org mode.sublime-syntax` => removed `task` file type.
4681* `SML.sublime_syntax` => removed `ml` file type.
47−* `Robot.sublime_syntax` => changed name to "Robot Framework"
82+* `Robot.sublime_syntax` => changed name to "Robot Framework", added `.resource` extension
4883
4984### Non-submodule additions
5085
@@ -59,3 +94,4 @@ The following files have been manually modified after converting from a `.tmLang
5994 https://github.com/seanjames777/SML-Language-Definition/blob/master/sml.tmLanguage
6095* `Cabal.sublime_syntax` has been added manually from
6196 https://github.com/SublimeHaskell/SublimeHaskell/ - we don't want to include the whole submodule because it includes other syntaxes ("Haskell improved") as well.
97+* `Lean.sublime-syntax` has been added manually from https://github.com/leanprover/vscode-lean/blob/master/syntaxes/lean.json via conversion.
tests/benchmarks/run-benchmarks.sh+48−4
@@ -1,28 +1,72 @@
11#!/usr/bin/env bash
2−
32cd "$(dirname "${BASH_SOURCE[0]}")" || exit
43
4+# Check that Hyperfine is installed.
55if ! command -v hyperfine > /dev/null 2>&1; then
66 echo "'hyperfine' does not seem to be installed."
77 echo "You can get it here: https://github.com/sharkdp/hyperfine"
88 exit 1
99fi
1010
11+# Determine the target directories.
12+get_target_dir() {
13+ if [[ -f "$HOME/.cargo/config" ]]; then
14+ grep 'target-dir[[:space:]]*=' "$HOME/.cargo/config" \
15+ | sed 's/^[[:space:]]*target-dir[[:space:]]*=//; s/^[[:space:]]*"//; s/"[[:space:]]*$//' \
16+ && return 0
17+ fi
18+
19+ echo "../../target"
20+}
21+
22+TARGET_DIR="$(get_target_dir)"
23+TARGET_DEBUG="${TARGET_DIR}/debug/bat"
24+TARGET_RELEASE="${TARGET_DIR}/release/bat"
25+
26+# Determine which target to benchmark.
27+BAT=''
28+for arg in "$@"; do
29+ case "$arg" in
30+ --system) BAT="bat" ;;
31+ --debug) BAT="$TARGET_DEBUG" ;;
32+ --release) BAT="$TARGET_RELEASE" ;;
33+ --bat=*) BAT="${arg:6}" ;;
34+ esac
35+done
36+
37+if [[ -z "$BAT" ]]; then
38+ echo "A build of 'bat' must be specified for benchmarking."
39+ echo "You can use '--system', '--debug', or '--release'."
40+ exit 1
41+fi
42+
43+# Ensure that the target is built.
44+if ! command -v "$BAT" &>/dev/null; then
45+ echo "Could not find the build of bat to benchmark."
46+ case "$BAT" in
47+ "bat") echo "Make you sure to symlink 'batcat' as 'bat'." ;;
48+ "$TARGET_DEBUG") echo "Make you sure to 'cargo build' first." ;;
49+ "$TARGET_RELEASE") echo "Make you sure to 'cargo build --release' first." ;;
50+ esac
51+ exit 1
52+fi
53+
54+# Run the benchmark.
1155echo "### Startup time"
1256echo
1357
14−hyperfine --warmup 3 bat
58+hyperfine --warmup 3 "$BAT"
1559
1660echo
1761echo "### Plain text"
1862echo
1963
20−hyperfine --warmup 3 "bat --language txt --paging=never 'test-src/jquery-3.3.1.js'"
64+hyperfine --warmup 3 "$(printf "%q" "$BAT") --language txt --paging=never 'test-src/jquery-3.3.1.js'"
2165
2266echo
2367echo "### Time to syntax-highlight large files"
2468echo
2569
2670for SRC in test-src/*; do
27− hyperfine --warmup 3 "bat --style=full --color=always --paging=never '$SRC'"
71+ hyperfine --warmup 3 "$(printf "%q" "$BAT") --style=full --color=always --paging=never $(printf "%q" "$SRC")"
2872done
tests/syntax-tests/highlighted/Lean/test.leannew file+68
@@ -0,0 +1,68 @@
1+import data.matrix.notation
2+import data.vector2
3+
4+/-!
5+
6+Helpers that don't currently fit elsewhere...
7+
8+-/
9+
10+lemma split_eq {m n : Type*} (x : m × n) (p p' : m × n) :
11+ p = x ∨ p' = x ∨ (x ≠ p ∧ x ≠ p') := by tauto
12+
13+-- For `playfield`s, the piece type and/or piece index type.
14+variables (X : Type*)
15+variables [has_repr X]
16+
17+namespace chess.utils
18+
19+section repr
20+
21+/--
22+An auxiliary wrapper for `option X` that allows for overriding the `has_repr` instance
23+for `option`, and rather, output just the value in the `some` and a custom provided
24+`string` for `none`.
25+-/
26+structure option_wrapper :=
27+(val : option X)
28+(none_s : string)
29+
30+instance wrapped_option_repr : has_repr (option_wrapper X) :=
31+⟨λ ⟨val, s⟩, (option.map has_repr.repr val).get_or_else s⟩
32+
33+variables {X}
34+/--
35+Construct an `option_wrapper` term from a provided `option X` and the `string`
36+that will override the `has_repr.repr` for `none`.
37+-/
38+def option_wrap (val : option X) (none_s : string) : option_wrapper X := ⟨val, none_s⟩
39+
40+-- The size of the "vectors" for a `fin n' → X`, for `has_repr` definitions
41+variables {m' n' : ℕ}
42+
43+/--
44+For a "vector" `X^n'` represented by the type `Π n' : ℕ, fin n' → X`, where
45+the `X` has a `has_repr` instance itself, we can provide a `has_repr` for the "vector".
46+This definition is used for displaying rows of the playfield, when it is defined
47+via a `matrix`, likely through notation.
48+-/
49+def vec_repr : Π {n' : ℕ}, (fin n' → X) → string :=
50+λ _ v, string.intercalate ", " ((vector.of_fn v).to_list.map repr)
51+
52+instance vec_repr_instance : has_repr (fin n' → X) := ⟨vec_repr⟩
53+
54+/--
55+For a `matrix` `X^(m' × n')` where the `X` has a `has_repr` instance itself,
56+we can provide a `has_repr` for the matrix, using `vec_repr` for each of the rows of the matrix.
57+This definition is used for displaying the playfield, when it is defined
58+via a `matrix`, likely through notation.
59+-/
60+def matrix_repr : Π {m' n'}, matrix (fin m') (fin n') X → string :=
61+λ _ _ M, string.intercalate ";\n" ((vector.of_fn M).to_list.map repr)
62+
63+instance matrix_repr_instance :
64+ has_repr (matrix (fin n') (fin m') X) := ⟨matrix_repr⟩
65+
66+end repr
67+
68+end chess.utils
tests/syntax-tests/highlighted/Zig/example.zignew file+107
@@ -0,0 +1,107 @@
1+//! this is a top level doc, starts with "//!"
2+
3+const std = @import("std");
4+
5+pub fn main() anyerror!void {
6+ const stdout = std.io.getStdOut().writer();
7+ try stdout.print("Hello, {}!\n", .{"world"});
8+}
9+
10+const expect = std.testing.expect;
11+
12+test "comments" {
13+ // comments start with "//" until newline
14+ // foo bar baz
15+ const x = true; // another comment
16+ expect(x);
17+}
18+
19+/// a doc comment starts with "///"
20+/// multiple lines are merged together
21+const Timestamp = struct {
22+ /// number of seconds since epoch
23+ seconds: i64,
24+
25+ /// number of nanoseconds past the second
26+ nano: u32,
27+
28+ const Self = @This();
29+
30+ pub fn unixEpoch() Self {
31+ return Self{
32+ .seconds = 0,
33+ .nanos = 0,
34+ };
35+ }
36+};
37+
38+const my_val = switch (std.Target.current.os.tag) {
39+ .linux => "Linux",
40+ else => "not Linux",
41+};
42+
43+const Book = enum {
44+ paperback,
45+ hardcover,
46+ ebook,
47+ pdf,
48+};
49+
50+const TokenType = union(enum) {
51+ int: isize,
52+ float: f64,
53+ string: []const u8,
54+};
55+
56+const array_lit: [4]u8 = .{ 11, 22, 33, 44 };
57+const sentinal_lit = [_:0]u8{ 1, 2, 3, 4 };
58+
59+test "address of syntax" {
60+ // Get the address of a variable:
61+ const x: i32 = 1234;
62+ const x_ptr = &x;
63+
64+ // Dereference a pointer:
65+ expect(x_ptr.* == 1234);
66+
67+ // When you get the address of a const variable, you get a const pointer to a single item.
68+ expect(@TypeOf(x_ptr) == *const i32);
69+
70+ // If you want to mutate the value, you'd need an address of a mutable variable:
71+ var y: i32 = 5678;
72+ const y_ptr = &y;
73+ expect(@TypeOf(y_ptr) == *i32);
74+ y_ptr.* += 1;
75+ expect(y_ptr.* == 5679);
76+}
77+
78+// integer literals
79+const decimal_int = 98222;
80+const hex_int = 0xff;
81+const another_hex_int = 0xFF;
82+const octal_int = 0o755;
83+const binary_int = 0b11110000;
84+
85+// underscores may be placed between two digits as a visual separator
86+const one_billion = 1_000_000_000;
87+const binary_mask = 0b1_1111_1111;
88+const permissions = 0o7_5_5;
89+const big_address = 0xFF80_0000_0000_0000;
90+
91+// float literals
92+const floating_point = 123.0E+77;
93+const another_float = 123.0;
94+const yet_another = 123.0e+77;
95+
96+const hex_floating_point = 0x103.70p-5;
97+const another_hex_float = 0x103.70;
98+const yet_another_hex_float = 0x103.70P-5;
99+
100+// underscores may be placed between two digits as a visual separator
101+const lightspeed = 299_792_458.000_000;
102+const nanosecond = 0.000_000_001;
103+const more_hex = 0x1234_5678.9ABC_CDEFp-10;
104+
105+fn max(comptime T: type, a: T, b: T) T {
106+ return if (a > b) a else b;
107+}
tests/syntax-tests/source/DotENV/.env+1−1
@@ -54,4 +54,4 @@ TEST_ESCAPE="escaped characters \n \t \r \" \' \$ or maybe a backslash \\..."
5454TEST_DOUBLE="Lorem {$VAR1} ${VAR2} $VAR3 ipsum dolor sit amet\n\r\t\\"
5555
5656# Single Quotes
57−TEST_SINGLE='Lorem {$VAR1} ${VAR2} $VAR3 ipsum dolor sit amet\n\r\t\\'
57+TEST_SINGLE='Lorem {$VAR1} ${VAR2} $VAR3 ipsum dolor sit amet\n\r\t\\'
tests/syntax-tests/source/Lean/test.leannew file+68
@@ -0,0 +1,68 @@
1+import data.matrix.notation
2+import data.vector2
3+
4+/-!
5+
6+Helpers that don't currently fit elsewhere...
7+
8+-/
9+
10+lemma split_eq {m n : Type*} (x : m × n) (p p' : m × n) :
11+ p = x ∨ p' = x ∨ (x ≠ p ∧ x ≠ p') := by tauto
12+
13+-- For `playfield`s, the piece type and/or piece index type.
14+variables (X : Type*)
15+variables [has_repr X]
16+
17+namespace chess.utils
18+
19+section repr
20+
21+/--
22+An auxiliary wrapper for `option X` that allows for overriding the `has_repr` instance
23+for `option`, and rather, output just the value in the `some` and a custom provided
24+`string` for `none`.
25+-/
26+structure option_wrapper :=
27+(val : option X)
28+(none_s : string)
29+
30+instance wrapped_option_repr : has_repr (option_wrapper X) :=
31+⟨λ ⟨val, s⟩, (option.map has_repr.repr val).get_or_else s⟩
32+
33+variables {X}
34+/--
35+Construct an `option_wrapper` term from a provided `option X` and the `string`
36+that will override the `has_repr.repr` for `none`.
37+-/
38+def option_wrap (val : option X) (none_s : string) : option_wrapper X := ⟨val, none_s⟩
39+
40+-- The size of the "vectors" for a `fin n' → X`, for `has_repr` definitions
41+variables {m' n' : ℕ}
42+
43+/--
44+For a "vector" `X^n'` represented by the type `Π n' : ℕ, fin n' → X`, where
45+the `X` has a `has_repr` instance itself, we can provide a `has_repr` for the "vector".
46+This definition is used for displaying rows of the playfield, when it is defined
47+via a `matrix`, likely through notation.
48+-/
49+def vec_repr : Π {n' : ℕ}, (fin n' → X) → string :=
50+λ _ v, string.intercalate ", " ((vector.of_fn v).to_list.map repr)
51+
52+instance vec_repr_instance : has_repr (fin n' → X) := ⟨vec_repr⟩
53+
54+/--
55+For a `matrix` `X^(m' × n')` where the `X` has a `has_repr` instance itself,
56+we can provide a `has_repr` for the matrix, using `vec_repr` for each of the rows of the matrix.
57+This definition is used for displaying the playfield, when it is defined
58+via a `matrix`, likely through notation.
59+-/
60+def matrix_repr : Π {m' n'}, matrix (fin m') (fin n') X → string :=
61+λ _ _ M, string.intercalate ";\n" ((vector.of_fn M).to_list.map repr)
62+
63+instance matrix_repr_instance :
64+ has_repr (matrix (fin n') (fin m') X) := ⟨matrix_repr⟩
65+
66+end repr
67+
68+end chess.utils
tests/syntax-tests/source/Svelte/LICENSE → tests/syntax-tests/source/Svelte/LICENSE.mdrenamed

The content is the same.

tests/syntax-tests/source/Zig/example.zignew file+107
@@ -0,0 +1,107 @@
1+//! this is a top level doc, starts with "//!"
2+
3+const std = @import("std");
4+
5+pub fn main() anyerror!void {
6+ const stdout = std.io.getStdOut().writer();
7+ try stdout.print("Hello, {}!\n", .{"world"});
8+}
9+
10+const expect = std.testing.expect;
11+
12+test "comments" {
13+ // comments start with "//" until newline
14+ // foo bar baz
15+ const x = true; // another comment
16+ expect(x);
17+}
18+
19+/// a doc comment starts with "///"
20+/// multiple lines are merged together
21+const Timestamp = struct {
22+ /// number of seconds since epoch
23+ seconds: i64,
24+
25+ /// number of nanoseconds past the second
26+ nano: u32,
27+
28+ const Self = @This();
29+
30+ pub fn unixEpoch() Self {
31+ return Self{
32+ .seconds = 0,
33+ .nanos = 0,
34+ };
35+ }
36+};
37+
38+const my_val = switch (std.Target.current.os.tag) {
39+ .linux => "Linux",
40+ else => "not Linux",
41+};
42+
43+const Book = enum {
44+ paperback,
45+ hardcover,
46+ ebook,
47+ pdf,
48+};
49+
50+const TokenType = union(enum) {
51+ int: isize,
52+ float: f64,
53+ string: []const u8,
54+};
55+
56+const array_lit: [4]u8 = .{ 11, 22, 33, 44 };
57+const sentinal_lit = [_:0]u8{ 1, 2, 3, 4 };
58+
59+test "address of syntax" {
60+ // Get the address of a variable:
61+ const x: i32 = 1234;
62+ const x_ptr = &x;
63+
64+ // Dereference a pointer:
65+ expect(x_ptr.* == 1234);
66+
67+ // When you get the address of a const variable, you get a const pointer to a single item.
68+ expect(@TypeOf(x_ptr) == *const i32);
69+
70+ // If you want to mutate the value, you'd need an address of a mutable variable:
71+ var y: i32 = 5678;
72+ const y_ptr = &y;
73+ expect(@TypeOf(y_ptr) == *i32);
74+ y_ptr.* += 1;
75+ expect(y_ptr.* == 5679);
76+}
77+
78+// integer literals
79+const decimal_int = 98222;
80+const hex_int = 0xff;
81+const another_hex_int = 0xFF;
82+const octal_int = 0o755;
83+const binary_int = 0b11110000;
84+
85+// underscores may be placed between two digits as a visual separator
86+const one_billion = 1_000_000_000;
87+const binary_mask = 0b1_1111_1111;
88+const permissions = 0o7_5_5;
89+const big_address = 0xFF80_0000_0000_0000;
90+
91+// float literals
92+const floating_point = 123.0E+77;
93+const another_float = 123.0;
94+const yet_another = 123.0e+77;
95+
96+const hex_floating_point = 0x103.70p-5;
97+const another_hex_float = 0x103.70;
98+const yet_another_hex_float = 0x103.70P-5;
99+
100+// underscores may be placed between two digits as a visual separator
101+const lightspeed = 299_792_458.000_000;
102+const nanosecond = 0.000_000_001;
103+const more_hex = 0x1234_5678.9ABC_CDEFp-10;
104+
105+fn max(comptime T: type, a: T, b: T) T {
106+ return if (a > b) a else b;
107+}