diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 0e4900e2..fa156757 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -28,11 +28,11 @@ If you're on Windows: **Describe the bug you encountered:** ... -**Describe what you expected to happen?** +**What did you expect to happen instead?** ... **How did you install `bat`?** -apt-get, homebrew, GitHub release, etc. + --- diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 5ff77927..66fb7c76 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -22,6 +22,12 @@ jobs: toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }} default: true profile: minimal # minimal component installation (ie, no documentation) + components: clippy + - name: Run clippy (on minimum supported rust version to prevent warnings we can't fix) + uses: actions-rs/cargo@v1 + with: + command: clippy + args: --all-targets --all-features -- --allow clippy::style - name: Test uses: actions-rs/cargo@v1 with: @@ -58,6 +64,11 @@ jobs: with: command: test args: --release + - name: Run ignored-by-default unit tests with new syntaxes and themes + uses: actions-rs/cargo@v1 + with: + command: test + args: --release -- --ignored - name: Syntax highlighting regression test run: tests/syntax-tests/regression_test.sh - name: List of languages @@ -147,6 +158,8 @@ jobs: echo ::set-output name=PKG_NAME::${PKG_NAME} # deployable tag? (ie, leading "vM" or "M"; M == version number) unset DEPLOY ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOY='true' ; fi + # unset deploy on ubuntu-18.04 x64 - we will deploy the tarball/deb built on ubuntu-16.04 x64 + if [ "${{ matrix.job.os }}" = "ubuntu-18.04" ] && [ "${{ matrix.job.target }}" = "x86_64-unknown-linux-gnu" ]; then unset DEPLOY; fi echo set-output name=DEPLOY::${DEPLOY:-/false} echo ::set-output name=DEPLOY::${DEPLOY} # DPKG architecture? @@ -302,18 +315,6 @@ jobs: install -Dm755 'target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}" if [ -n "${{ steps.vars.outputs.STRIP }}" ]; then "${{ steps.vars.outputs.STRIP }}" "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}" ; fi - # Work out shared library dependencies - # dpkg-shlibdeps requires debian/control file. Dummy it and clean up - mkdir "./debian" - touch "./debian/control" - case ${{ matrix.job.target }} in - aarch64-*-linux-*) DEPENDS="$(dpkg-shlibdeps -l/usr/aarch64-linux-gnu/lib -O "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}" 2> /dev/null | sed 's/^shlibs:Depends=//')" ;; - arm-*-linux-*hf) DEPENDS="$(dpkg-shlibdeps -l/usr/arm-linux-gnueabihf/lib -O "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}" 2> /dev/null | sed 's/^shlibs:Depends=//')" ;; - i686-*-linux-*) DEPENDS="$(dpkg-shlibdeps -O "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}" 2> /dev/null | sed 's/^shlibs:Depends=//')" ;; - x86_64-*-linux-*) DEPENDS="$(dpkg-shlibdeps -O "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}" 2> /dev/null | sed 's/^shlibs:Depends=//')" ;; - esac; - rm -rf "./debian" - # Man page install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/manual/bat.1 "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1" gzip -n --best "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1" @@ -380,7 +381,6 @@ jobs: Maintainer: ${{ env.PROJECT_MAINTAINER }} Homepage: ${{ env.PROJECT_HOMEPAGE }} Architecture: ${{ steps.vars.outputs.DPKG_ARCH }} - Depends: $DEPENDS Provides: ${{ env.PROJECT_NAME }} Conflicts: ${{ steps.vars.outputs.DPKG_CONFLICTS }} Description: cat(1) clone with wings. diff --git a/.gitmodules b/.gitmodules index 1d94f27e..99364ba6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -185,9 +185,6 @@ [submodule "assets/syntaxes/02_Extra/AsciiDoc"] path = assets/syntaxes/02_Extra/AsciiDoc url = https://github.com/asciidoctor/sublimetext-asciidoc.git -[submodule "assets/themes/gruvbox"] - path = assets/themes/gruvbox - url = https://github.com/peaceant/gruvbox.git [submodule "assets/syntaxes/02_Extra/GLSL"] path = assets/syntaxes/02_Extra/GLSL url = https://github.com/euler0/sublime-glsl @@ -197,3 +194,22 @@ [submodule "assets/syntaxes/02_Extra/Apache"] path = assets/syntaxes/02_Extra/Apache url = https://github.com/colinta/ApacheConf.tmLanguage +[submodule "assets/syntaxes/02_Extra/Ninja"] + path = assets/syntaxes/02_Extra/Ninja + url = https://github.com/pope/SublimeNinja.git +[submodule "assets/syntaxes/02_Extra/Svelte"] + path = assets/syntaxes/02_Extra/Svelte + url = https://github.com/corneliusio/svelte-sublime +[submodule "assets/themes/Coldark"] + path = assets/themes/Coldark + url = https://github.com/ArmandPhilippot/coldark-bat.git +[submodule "assets/themes/gruvbox"] + path = assets/themes/gruvbox + url = https://github.com/subnut/gruvbox-tmTheme.git + branch = bat-source +[submodule "assets/syntaxes/02_Extra/Lean"] + path = assets/syntaxes/02_Extra/Lean + url = https://github.com/leanprover/vscode-lean.git +[submodule "assets/syntaxes/02_Extra/Zig"] + path = assets/syntaxes/02_Extra/Zig + url = https://github.com/ziglang/sublime-zig-language.git diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ac3cd4e..c04f8e97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,21 +1,75 @@ # unreleased -- Add Note to refer to see detailed help with --help (and vice versa with -h). see #1215 (@henil) ## Features +- Use a pager when `bat --list-languages` is called, see #1394 (@stku1985) ## Bugfixes +- If the last line doesn't end with a newline character, don't add it if `--style=plain`, see #1438 (@Enselic) +- Only print themes hint in interactive mode (`bat --list-themes`), see #1439 (@rsteube) +- Make ./tests/syntax-tests/regression_test.sh work on recent versions of macOS, see #1443 (@Enselic) +- VimL syntax highlighting fix, see #1450 (@esensar) +- Print an 'Invalid syntax theme settings' error message if a custom theme is broken, see #614 (@Enselic) + ## Other +- Performance improvements, see #1421 (@LovecraftianHorror) + ## Syntaxes +- Added Zig syntax, see #1470 (@paulsmith) +- Added Lean syntax, see #1446 (@Julian) +- Added `.resource` extension for Robot Framework files, see #1386 + ## New themes +- `ansi` replaces `ansi-dark` and `ansi-light`, see #1104 and #1412 (@mk12) +- The Gruvbox theme has been updated, see #1291 (@j0hnmeow). **Breaking change:** users that were previously usuing `gruvbox` or `gruvbox-white` should update and use `gruvbox-dark`/`gruvbox-light` instead. + ## `bat` as a library ## Packaging +- `bat` is now available on snapstore with package name called `batcat`, see #1401 (@purveshpatel511) + + +# v0.17.1 + +## Bugfixes + +- Running `bat` without arguments fails ("output file is also an input"), see #1396 + + +# v0.17.0 + +## Features + +- Added a new `--style` value, `rule`, which adds a simple horizontal ruled line between files, see #1276 (@tommilligan) +- Pass `-S` ("chop long lines") to `less` if `--wrap=never` is set in `bat`, see #1255 (@gahag) + +## Bugfixes + +- Detect infinite loop when input and output are the same, see #1193 and #1197 (@niklasmohrin) +- Throw an error when `bat` is being used as `pager`, see #1343 (@adrian-rivera) +- Bash syntax highlighting not selected for `*.ebuild` and `*.eclass` files, see #1292 (@sharkdp) +- Fix `zsh` completion when using `-p`, see #1320 (@xzfc) + +## Other + +- Add note to refer to see detailed help with `--help` (and vice versa with `-h`), see #1215 (@henil) +- Add a `Contributors` section to `README`, see #1348 (@adrian-rivera) + +## Syntaxes + +- Manpage syntax highlighting has been improved, see #1315 (@keith-hall) +- Add Svelte file syntax, see #1285 (@kjmph) + +## New themes + +- Coldark, see #1329 (@armandphilippot) + + # v0.16.0 ## Features diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..a1770575 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,48 @@ +# Contributing + +Thank you for considering to contribute to `bat`! + + + +## Add an entry to the changelog + +If your contribution changes the behavior of `bat` (as opposed to a typo-fix +in the documentation), please update the [`CHANGELOG.md`](CHANGELOG.md) file +and describe your changes. This makes the release process much easier and +therefore helps to get your changes into a new `bat` release faster. + +The top of the `CHANGELOG` contains a *"unreleased"* section with a few +subsections (Features, Bugfixes, …). Please add your entry to the subsection +that best describes your change. + +Entries follow this format: +``` +- Short description of what has been changed, see #123 (@user) +``` +Here, `#123` is the number of the original issue and/or your pull request. +Please replace `@user` by your GitHub username. + + +## Development + +Please check out the [Development](https://github.com/sharkdp/bat#development) +section in the README. + + +## Adding a new feature + +Please consider opening a +[feature request ticket](https://github.com/sharkdp/bat/issues/new?assignees=&labels=feature-request&template=feature_request.md) +first in order to give us a chance to discuss the feature first. + + +## Adding new syntaxes/languages or themes + +Before you make a pull request that adds a new syntax or theme, please read +the [Customization](https://github.com/sharkdp/bat#customization) section +in the README first. + +If you really think that a particular syntax or theme should be added for all +users, please read the corresponding +[documentation](https://github.com/sharkdp/bat/blob/master/doc/assets.md) +first. diff --git a/Cargo.lock b/Cargo.lock index 81c444c4..5d7eda7e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,1308 +4,1295 @@ name = "adler" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" [[package]] name = "aho-corasick" version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86" dependencies = [ - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr", ] [[package]] name = "ansi_colours" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d0f302a81afc6a7f4350c04f0ba7cfab529cc009bca3324b3fb5764e6add8b6" dependencies = [ - "cc 1.0.60 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", ] [[package]] name = "ansi_term" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" dependencies = [ - "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi", ] [[package]] name = "ansi_term" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ - "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi", ] [[package]] name = "arrayref" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" [[package]] name = "arrayvec" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" [[package]] name = "assert_cmd" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dc1679af9a1ab4bea16f228b05d18f8363f8327b1fa8db00d2760cfafc6b61e" dependencies = [ - "doc-comment 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "predicates 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wait-timeout 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "doc-comment", + "predicates", + "predicates-core", + "predicates-tree", + "wait-timeout", ] [[package]] name = "atty" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "hermit-abi", + "libc", + "winapi", ] [[package]] name = "autocfg" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "base64" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" [[package]] name = "bat" -version = "0.16.0" +version = "0.17.1" dependencies = [ - "ansi_colours 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", - "assert_cmd 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "console 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "content_inspector 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "dirs 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)", - "globset 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "path_abs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "predicates 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "semver 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_yaml 0.8.13 (registry+https://github.com/rust-lang/crates.io-index)", - "shell-words 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntect 4.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "wild 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_colours", + "ansi_term 0.12.1", + "assert_cmd", + "atty", + "clap", + "console", + "content_inspector", + "dirs", + "encoding", + "error-chain", + "git2", + "globset", + "lazy_static", + "path_abs", + "predicates", + "semver", + "serde", + "serde_yaml", + "shell-words", + "syntect", + "tempdir", + "unicode-width", + "wild", ] [[package]] name = "bincode" version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d" dependencies = [ - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", + "serde", ] [[package]] name = "bit-set" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" dependencies = [ - "bit-vec 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bit-vec", ] [[package]] name = "bit-vec" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0dc55f2d8a1a85650ac47858bb001b4c0dd73d79e3c455a842925e68d29cd3" [[package]] name = "bitflags" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "blake2b_simd" version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" dependencies = [ - "arrayref 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "constant_time_eq 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayref", + "arrayvec", + "constant_time_eq", ] [[package]] name = "block-buffer" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ - "block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "block-padding", + "byte-tools", + "byteorder", + "generic-array", ] [[package]] name = "block-padding" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" dependencies = [ - "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byte-tools", ] [[package]] name = "bstr" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31accafdb70df7871592c058eca3985b71104e15ac32f64706022c58867da931" dependencies = [ - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr", ] [[package]] name = "byte-tools" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "cc" version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef611cc68ff783f18535d77ddd080185275713d852c4f5cbb6122c462a7a825c" dependencies = [ - "jobserver 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "jobserver", ] [[package]] name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "chrono" version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" dependencies = [ - "num-integer 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer", + "num-traits", ] [[package]] name = "clap" version = "2.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" dependencies = [ - "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term_size 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "vec_map 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.11.0", + "atty", + "bitflags", + "strsim", + "term_size", + "textwrap", + "unicode-width", + "vec_map", ] [[package]] name = "console" -version = "0.12.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cc80946b3480f421c2f17ed1cb841753a371c7c5104f51d507e13f532c856aa" dependencies = [ - "encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "terminal_size 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "termios 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "encode_unicode", + "lazy_static", + "libc", + "regex", + "terminal_size", + "unicode-width", + "winapi", ] [[package]] name = "constant_time_eq" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "content_inspector" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7bda66e858c683005a53a9a60c69a4aca7eeaa45d124526e389f7aec8e62f38" dependencies = [ - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr", ] [[package]] name = "crc32fast" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", ] [[package]] name = "crossbeam-utils" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ - "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "cfg-if", + "lazy_static", ] [[package]] name = "difference" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" [[package]] name = "digest" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array", ] [[package]] name = "dirs" version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "142995ed02755914747cc6ca76fc7e4583cd18578746716d0508ea6ed558b9ff" dependencies = [ - "dirs-sys 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "dirs-sys", ] [[package]] name = "dirs-sys" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a" dependencies = [ - "libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_users 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "redox_users", + "winapi", ] [[package]] name = "doc-comment" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "dtoa" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b" [[package]] name = "encode_unicode" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding" version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec" dependencies = [ - "encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding-index-korean 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding-index-simpchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding-index-japanese", + "encoding-index-korean", + "encoding-index-simpchinese", + "encoding-index-singlebyte", + "encoding-index-tradchinese", ] [[package]] name = "encoding-index-japanese" version = "1.20141219.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91" dependencies = [ - "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_index_tests", ] [[package]] name = "encoding-index-korean" version = "1.20141219.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81" dependencies = [ - "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_index_tests", ] [[package]] name = "encoding-index-simpchinese" version = "1.20141219.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7" dependencies = [ - "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_index_tests", ] [[package]] name = "encoding-index-singlebyte" version = "1.20141219.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a" dependencies = [ - "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_index_tests", ] [[package]] name = "encoding-index-tradchinese" version = "1.20141219.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" dependencies = [ - "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_index_tests", ] [[package]] name = "encoding_index_tests" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" [[package]] name = "error-chain" version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" dependencies = [ - "version_check 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check", ] [[package]] name = "fake-simd" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" [[package]] name = "fancy-regex" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae91abf6555234338687bb47913978d275539235fcb77ba9863b779090b42b14" dependencies = [ - "bit-set 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "bit-set", + "regex", ] [[package]] name = "flate2" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da80be589a72651dcda34d8b35bcdc9b7254ad06325611074d9cc0fbb19f60ee" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "crc32fast", + "libc", + "miniz_oxide", ] [[package]] name = "float-cmp" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1267f4ac4f343772758f7b1bdcbe767c218bbab93bb432acbf5162bbf85a6c4" dependencies = [ - "num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits", ] [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fuchsia-cprng" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" [[package]] name = "generic-array" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" dependencies = [ - "typenum 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum", ] [[package]] name = "getrandom" version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)", - "wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "libc", + "wasi", ] [[package]] name = "git2" -version = "0.13.11" +version = "0.13.15" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44f267c9da8a4de3c615b59e23606c75f164f84896e97f4dd6c15a4294de4359" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.12.13+1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "libc", + "libgit2-sys", + "log", + "url", ] [[package]] name = "glob" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "globset" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c152169ef1e421390738366d2f796655fec62621dabbd0fd476f905934061e4a" dependencies = [ - "aho-corasick 0.7.13 (registry+https://github.com/rust-lang/crates.io-index)", - "bstr 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick", + "bstr", + "fnv", + "log", + "regex", ] [[package]] name = "hashbrown" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" [[package]] name = "hermit-abi" version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c30f6d0bc6b00693347368a67d41b58f2fb851215ff1da49e90fe2c5c667151" dependencies = [ - "libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "idna" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" dependencies = [ - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "matches", + "unicode-bidi", + "unicode-normalization", ] [[package]] name = "indexmap" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" dependencies = [ - "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "hashbrown 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "hashbrown", ] [[package]] name = "itoa" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" [[package]] name = "jobserver" version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" dependencies = [ - "libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "lazycell" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa7087f49d294270db4e1928fc110c976cd4b9e5a16348e0a1df09afa99e6c98" [[package]] name = "libgit2-sys" -version = "0.12.13+1.0.1" +version = "0.12.17+1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4ebdf65ca745126df8824688637aa0535a88900b83362d8ca63893bcf4e8841" dependencies = [ - "cc 1.0.60 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", + "libc", + "libz-sys", + "pkg-config", ] [[package]] name = "libz-sys" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "602113192b08db8f38796c4e85c39e960c145965140e918018bcde1952429655" dependencies = [ - "cc 1.0.60 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", + "libc", + "pkg-config", + "vcpkg", ] [[package]] name = "line-wrap" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" dependencies = [ - "safemem 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "safemem", ] [[package]] name = "linked-hash-map" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" [[package]] name = "log" version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", ] [[package]] name = "maplit" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" [[package]] name = "matches" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" [[package]] name = "memchr" version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" [[package]] name = "miniz_oxide" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c60c0dfe32c10b43a144bad8fc83538c52f58302c92300ea7ec7bf7b38d5a7b9" dependencies = [ - "adler 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "adler", + "autocfg", ] [[package]] name = "normalize-line-endings" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "num-integer" version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" dependencies = [ - "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "num-traits", ] [[package]] name = "num-traits" version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" dependencies = [ - "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", ] [[package]] name = "onig" version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a155d13862da85473665694f4c05d77fb96598bdceeaf696433c84ea9567e20" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)", - "onig_sys 69.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "lazy_static", + "libc", + "onig_sys", ] [[package]] name = "onig_sys" version = "69.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bff06597a6b17855040955cae613af000fc0bfc8ad49ea68b9479a74e59292d" dependencies = [ - "cc 1.0.60 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", + "pkg-config", ] [[package]] name = "opaque-debug" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "path_abs" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb6b8e6dede0bf94e9300e669f335ba92d5fc9fc8be7f4b1ca8a05206489388c" dependencies = [ - "std_prelude 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "std_prelude", ] [[package]] name = "percent-encoding" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "pest" version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" dependencies = [ - "ucd-trie 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ucd-trie", ] [[package]] name = "pest_derive" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" dependencies = [ - "pest 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pest_generator 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "pest", + "pest_generator", ] [[package]] name = "pest_generator" version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" dependencies = [ - "pest 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pest_meta 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "pest_meta" version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" dependencies = [ - "maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "pest 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "sha-1 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "maplit", + "pest", + "sha-1", ] [[package]] name = "pkg-config" version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" [[package]] name = "plist" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b336d94e8e4ce29bf15bba393164629764744c567e8ad306cc1fdd0119967fd" dependencies = [ - "base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "line-wrap 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)", - "xml-rs 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", + "base64", + "chrono", + "indexmap", + "line-wrap", + "serde", + "xml-rs", ] [[package]] name = "predicates" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73dd9b7b200044694dfede9edf907c1ca19630908443e9447e624993700c6932" dependencies = [ - "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "float-cmp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "normalize-line-endings 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "difference", + "float-cmp", + "normalize-line-endings", + "predicates-core", + "regex", ] [[package]] name = "predicates-core" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" [[package]] name = "predicates-tree" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" dependencies = [ - "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "predicates-core", + "treeline", ] [[package]] name = "proc-macro2" version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" dependencies = [ - "unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid", ] [[package]] name = "quote" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" dependencies = [ - "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", ] [[package]] name = "rand" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" dependencies = [ - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "rdrand", + "winapi", ] [[package]] name = "rand_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" dependencies = [ - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2", ] [[package]] name = "rand_core" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" [[package]] name = "rdrand" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1", ] [[package]] name = "redox_syscall" version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "redox_users" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ - "getrandom 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)", - "rust-argon2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom", + "redox_syscall", + "rust-argon2", ] [[package]] name = "regex" -version = "1.3.9" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" dependencies = [ - "aho-corasick 0.7.13 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", ] [[package]] name = "regex-syntax" -version = "0.6.18" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" [[package]] name = "remove_dir_all" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi", ] [[package]] name = "rust-argon2" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19" dependencies = [ - "base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", - "blake2b_simd 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", - "constant_time_eq 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "base64", + "blake2b_simd", + "constant_time_eq", + "crossbeam-utils", ] [[package]] name = "ryu" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "safemem" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" [[package]] name = "same-file" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ - "winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util", ] [[package]] name = "semver" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" dependencies = [ - "semver-parser 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver-parser", ] [[package]] name = "semver-parser" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e012c6c5380fb91897ba7b9261a0f565e624e869d42fe1a1d03fa0d68a083d5" dependencies = [ - "pest 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pest", + "pest_derive", ] [[package]] name = "serde" -version = "1.0.116" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" dependencies = [ - "serde_derive 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.116" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" dependencies = [ - "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "serde_json" version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a230ea9107ca2220eea9d46de97eddcb04cd00e92d13dda78e478dd33fa82bd4" dependencies = [ - "itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa", + "ryu", + "serde", ] [[package]] name = "serde_yaml" -version = "0.8.13" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7baae0a99f1a324984bcdc5f0718384c1f69775f1c7eec8b859b71b443e3fd7" dependencies = [ - "dtoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "linked-hash-map 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)", - "yaml-rust 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "dtoa", + "linked-hash-map", + "serde", + "yaml-rust", ] [[package]] name = "sha-1" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" dependencies = [ - "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "block-buffer", + "digest", + "fake-simd", + "opaque-debug", ] [[package]] name = "shell-words" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074" [[package]] name = "std_prelude" version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8207e78455ffdf55661170876f88daf85356e4edd54e0a3dbc79586ca1e50cbe" [[package]] name = "strsim" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "syn" version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c51d92969d209b54a98397e1b91c8ae82d8c87a7bb87df0b29aa2ad81454228" dependencies = [ - "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] name = "syntect" -version = "4.4.0" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bfac2b23b4d049dc9a89353b4e06bbc85a8f42020cccbe5409a115cf19031e5" dependencies = [ - "bincode 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fancy-regex 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazycell 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "onig 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "plist 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.58 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "yaml-rust 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bincode", + "bitflags", + "fancy-regex", + "flate2", + "fnv", + "lazy_static", + "lazycell", + "onig", + "plist", + "regex-syntax", + "serde", + "serde_derive", + "serde_json", + "walkdir", + "yaml-rust", ] [[package]] name = "tempdir" version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" dependencies = [ - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "remove_dir_all 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand", + "remove_dir_all", ] [[package]] name = "term_size" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" dependencies = [ - "libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "winapi", ] [[package]] name = "terminal_size" -version = "0.1.13" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bd2d183bd3fac5f5fe38ddbeb4dc9aec4a39a9d7d59e7491d900302da01cbe1" dependencies = [ - "libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "termios" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "winapi", ] [[package]] name = "textwrap" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" dependencies = [ - "term_size 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "term_size", + "unicode-width", ] [[package]] name = "thread_local" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static", ] [[package]] name = "tinyvec" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" [[package]] name = "treeline" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" [[package]] name = "typenum" version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" [[package]] name = "ucd-trie" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" [[package]] name = "unicode-bidi" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" dependencies = [ - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "matches", ] [[package]] name = "unicode-normalization" version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977" dependencies = [ - "tinyvec 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tinyvec", ] [[package]] name = "unicode-width" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "url" version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" dependencies = [ - "idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "idna", + "matches", + "percent-encoding", ] [[package]] name = "vcpkg" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" [[package]] name = "vec_map" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" [[package]] name = "wait-timeout" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" dependencies = [ - "libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "walkdir" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" dependencies = [ - "same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "same-file", + "winapi", + "winapi-util", ] [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wild" version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "035793abb854745033f01a07647a79831eba29ec0be377205f2a25b0aa830020" dependencies = [ - "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glob", ] [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ - "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi", ] [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "xml-rs" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a" [[package]] name = "yaml-rust" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39f0c922f1a334134dc2f7a8b67dc5d25f0735263feec974345ff706bcf20b0d" dependencies = [ - "linked-hash-map 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "linked-hash-map", ] - -[metadata] -"checksum adler 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" -"checksum aho-corasick 0.7.13 (registry+https://github.com/rust-lang/crates.io-index)" = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86" -"checksum ansi_colours 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1d0f302a81afc6a7f4350c04f0ba7cfab529cc009bca3324b3fb5764e6add8b6" -"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -"checksum ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -"checksum arrayref 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" -"checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" -"checksum assert_cmd 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c88b9ca26f9c16ec830350d309397e74ee9abdfd8eb1f71cb6ecc71a3fc818da" -"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -"checksum autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" -"checksum base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" -"checksum bincode 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d" -"checksum bit-set 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" -"checksum bit-vec 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5f0dc55f2d8a1a85650ac47858bb001b4c0dd73d79e3c455a842925e68d29cd3" -"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -"checksum blake2b_simd 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" -"checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -"checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -"checksum bstr 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "31accafdb70df7871592c058eca3985b71104e15ac32f64706022c58867da931" -"checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" -"checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" -"checksum cc 1.0.60 (registry+https://github.com/rust-lang/crates.io-index)" = "ef611cc68ff783f18535d77ddd080185275713d852c4f5cbb6122c462a7a825c" -"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum chrono 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)" = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" -"checksum clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)" = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" -"checksum console 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b1aacfaffdbff75be81c15a399b4bedf78aaefe840e8af1d299ac2ade885d2" -"checksum constant_time_eq 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" -"checksum content_inspector 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b7bda66e858c683005a53a9a60c69a4aca7eeaa45d124526e389f7aec8e62f38" -"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" -"checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -"checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" -"checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -"checksum dirs 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "142995ed02755914747cc6ca76fc7e4583cd18578746716d0508ea6ed558b9ff" -"checksum dirs-sys 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a" -"checksum doc-comment 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" -"checksum dtoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b" -"checksum encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" -"checksum encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec" -"checksum encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91" -"checksum encoding-index-korean 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81" -"checksum encoding-index-simpchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7" -"checksum encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a" -"checksum encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" -"checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" -"checksum error-chain 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" -"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" -"checksum fancy-regex 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91abf6555234338687bb47913978d275539235fcb77ba9863b779090b42b14" -"checksum flate2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "da80be589a72651dcda34d8b35bcdc9b7254ad06325611074d9cc0fbb19f60ee" -"checksum float-cmp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1267f4ac4f343772758f7b1bdcbe767c218bbab93bb432acbf5162bbf85a6c4" -"checksum fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -"checksum getrandom 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" -"checksum git2 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)" = "1e094214efbc7fdbbdee952147e493b00e99a4e52817492277e98967ae918165" -"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" -"checksum globset 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7ad1da430bd7281dde2576f44c84cc3f0f7b475e7202cd503042dff01a8c8120" -"checksum hashbrown 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" -"checksum hermit-abi 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c30f6d0bc6b00693347368a67d41b58f2fb851215ff1da49e90fe2c5c667151" -"checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" -"checksum indexmap 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" -"checksum itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" -"checksum jobserver 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" -"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum lazycell 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" -"checksum libc 0.2.78 (registry+https://github.com/rust-lang/crates.io-index)" = "aa7087f49d294270db4e1928fc110c976cd4b9e5a16348e0a1df09afa99e6c98" -"checksum libgit2-sys 0.12.13+1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "069eea34f76ec15f2822ccf78fe0cdb8c9016764d0a12865278585a74dbdeae5" -"checksum libz-sys 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "602113192b08db8f38796c4e85c39e960c145965140e918018bcde1952429655" -"checksum line-wrap 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" -"checksum linked-hash-map 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" -"checksum log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" -"checksum maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" -"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" -"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" -"checksum miniz_oxide 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c60c0dfe32c10b43a144bad8fc83538c52f58302c92300ea7ec7bf7b38d5a7b9" -"checksum normalize-line-endings 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" -"checksum num-integer 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" -"checksum num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" -"checksum onig 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a155d13862da85473665694f4c05d77fb96598bdceeaf696433c84ea9567e20" -"checksum onig_sys 69.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9bff06597a6b17855040955cae613af000fc0bfc8ad49ea68b9479a74e59292d" -"checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" -"checksum path_abs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eb6b8e6dede0bf94e9300e669f335ba92d5fc9fc8be7f4b1ca8a05206489388c" -"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" -"checksum pest 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" -"checksum pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" -"checksum pest_generator 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" -"checksum pest_meta 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" -"checksum pkg-config 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" -"checksum plist 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b336d94e8e4ce29bf15bba393164629764744c567e8ad306cc1fdd0119967fd" -"checksum predicates 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96bfead12e90dccead362d62bb2c90a5f6fc4584963645bc7f71a735e0b0735a" -"checksum predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" -"checksum predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" -"checksum proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" -"checksum quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" -"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" -"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)" = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" -"checksum redox_users 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" -"checksum regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" -"checksum regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)" = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" -"checksum remove_dir_all 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -"checksum rust-argon2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19" -"checksum ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" -"checksum safemem 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" -"checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -"checksum semver 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -"checksum semver-parser 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e012c6c5380fb91897ba7b9261a0f565e624e869d42fe1a1d03fa0d68a083d5" -"checksum serde 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)" = "96fe57af81d28386a513cbc6858332abc6117cfdb5999647c6444b8f43a370a5" -"checksum serde_derive 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)" = "f630a6370fd8e457873b4bd2ffdae75408bc291ba72be773772a4c2a065d9ae8" -"checksum serde_json 1.0.58 (registry+https://github.com/rust-lang/crates.io-index)" = "a230ea9107ca2220eea9d46de97eddcb04cd00e92d13dda78e478dd33fa82bd4" -"checksum serde_yaml 0.8.13 (registry+https://github.com/rust-lang/crates.io-index)" = "ae3e2dd40a7cdc18ca80db804b7f461a39bb721160a85c9a1fa30134bf3c02a5" -"checksum sha-1 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" -"checksum shell-words 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074" -"checksum std_prelude 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "8207e78455ffdf55661170876f88daf85356e4edd54e0a3dbc79586ca1e50cbe" -"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -"checksum syn 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)" = "9c51d92969d209b54a98397e1b91c8ae82d8c87a7bb87df0b29aa2ad81454228" -"checksum syntect 4.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4e3978df05b5850c839a6b352d3c35ce0478944a4be689be826b53cf75363e88" -"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" -"checksum term_size 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" -"checksum terminal_size 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9a14cd9f8c72704232f0bfc8455c0e861f0ad4eb60cc9ec8a170e231414c1e13" -"checksum termios 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6f0fcee7b24a25675de40d5bb4de6e41b0df07bc9856295e7e2b3a3600c400c2" -"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -"checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -"checksum tinyvec 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" -"checksum treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" -"checksum typenum 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" -"checksum ucd-trie 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" -"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -"checksum unicode-normalization 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977" -"checksum unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" -"checksum unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" -"checksum url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" -"checksum vcpkg 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" -"checksum vec_map 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" -"checksum version_check 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" -"checksum wait-timeout 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" -"checksum walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" -"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -"checksum wild 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "035793abb854745033f01a07647a79831eba29ec0be377205f2a25b0aa830020" -"checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum xml-rs 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a" -"checksum yaml-rust 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "39f0c922f1a334134dc2f7a8b67dc5d25f0735263feec974345ff706bcf20b0d" diff --git a/Cargo.toml b/Cargo.toml index 6d9d75a5..6afe7523 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,9 +5,8 @@ description="A cat(1) clone with wings." homepage = "https://github.com/sharkdp/bat" license = "MIT/Apache-2.0" name = "bat" -readme = "README.md" repository = "https://github.com/sharkdp/bat" -version = "0.16.0" +version = "0.17.1" exclude = [ "assets/syntaxes/*", "assets/themes/*", @@ -38,7 +37,7 @@ regex-fancy = ["syntect/regex-fancy"] # Use the rust-only "fancy-regex" engine atty = { version = "0.2.14", optional = true } ansi_term = "^0.12.1" ansi_colours = "^1.0" -console = "0.12.0" +console = "0.14.0" dirs = { version = "3.0", optional = true } lazy_static = { version = "1.4", optional = true } wild = { version = "2.0", optional = true } @@ -58,7 +57,7 @@ optional = true default-features = false [dependencies.syntect] -version = "4.4.0" +version = "4.5.0" default-features = false features = ["parsing", "yaml-load", "dump-load", "dump-create"] @@ -74,8 +73,8 @@ default-features = false [dev-dependencies] tempdir = "0.3" -assert_cmd = "1.0.1" -predicates = "1.0.5" +assert_cmd = "1.0.2" +predicates = "1.0.6" [build-dependencies] clap = { version = "2.33", optional = true } diff --git a/README.md b/README.md index b6d558b7..9a31db62 100644 --- a/README.md +++ b/README.md @@ -38,14 +38,14 @@ characters: ### Automatic paging -`bat` can pipe its own output to a pager (e.g `less`) if the output is too large for one screen. +By default, `bat` pipes its own output to a pager (e.g `less`) if the output is too large for one screen. +If you would rather `bat` work like `cat` all the time (never page output), you can set `--paging=never` as an option, either on the command line or in your configuration file. +If you intend to alias `cat` to `bat` in your shell configuration, you can use `alias cat='bat --paging=never'` to preserve the default behavior. -### File concatenation +#### File concatenation -Oh.. you can also use it to concatenate files :wink:. Whenever -`bat` detects a non-interactive terminal (i.e. when you pipe into another process -or into a file), `bat` will act as a drop-in replacement for `cat` and -fall back to printing the plain file contents. +Even with a pager set, you can still use `bat` to concatenate files :wink:. +Whenever `bat` detects a non-interactive terminal (i.e. when you pipe into another process or into a file), `bat` will act as a drop-in replacement for `cat` and fall back to printing the plain file contents, regardless of the `--pager` option's value. ## How to use @@ -131,7 +131,18 @@ highlighting: git show v0.6.0:src/main.rs | bat -l rs ``` -Note that syntax highlighting within diffs is currently not supported. If you are looking for this, check out [`delta`](https://github.com/dandavison/delta). +#### `git diff` + +You can combine `bat` with `git diff` to view lines around code changes with proper syntax +highlighting: +```bash +batdiff() { + git diff --name-only --diff-filter=d | xargs bat --diff +} +``` +If you prefer to use this as a separate tool, check out `batdiff` in [`bat-extras`](https://github.com/eth-p/bat-extras). + +If you are looking for more support for git and diff operations, check out [`delta`](https://github.com/dandavison/delta). #### `xclip` @@ -169,7 +180,7 @@ The [`prettybat`](https://github.com/eth-p/bat-extras/blob/master/doc/prettybat. ## Installation -[![Packaging status](https://repology.org/badge/vertical-allrepos/bat.svg)](https://repology.org/project/bat/versions) +[![Packaging status](https://repology.org/badge/vertical-allrepos/bat-cat.svg)](https://repology.org/project/bat-cat/versions) ### On Ubuntu (using `apt`) *... and other Debian-based Linux distributions.* @@ -185,7 +196,7 @@ If your Ubuntu/Debian installation is new enough you can simply run: apt install bat ``` -If you install `bat` this way, please note that the executable may be installed as `batcat` instead of `bat` (due to [a name +**Important**: If you install `bat` this way, please note that the executable may be installed as `batcat` instead of `bat` (due to [a name clash with another package](https://github.com/sharkdp/bat/issues/982)). You can set up a `bat -> batcat` symlink or alias to prevent any issues that may come up because of this and to be consistent with other distributions: ``` bash mkdir -p ~/.local/bin @@ -200,7 +211,7 @@ the most recent release of `bat`, download the latest `.deb` package from the [release page](https://github.com/sharkdp/bat/releases) and install it via: ```bash -sudo dpkg -i bat_0.16.0_amd64.deb # adapt version number and architecture +sudo dpkg -i bat_0.17.1_amd64.deb # adapt version number and architecture ``` ### On Alpine Linux @@ -245,6 +256,13 @@ You can install `bat` via xbps-install: xbps-install -S bat ``` +### On Termux + +You can install `bat` via pkg: +```bash +pkg install bat +``` + ### On FreeBSD You can install a precompiled [`bat` package](https://www.freshports.org/textproc/bat) with pkg: @@ -276,6 +294,15 @@ You can install `bat` with zypper: zypper install bat ``` +### Via snap package + +``` +sudo snap install batcat +``` + +[Get it from the Snap Store](https://snapcraft.io/batcat) + + ### On macOS (or Linux) via Homebrew You can install `bat` with [Homebrew on MacOS](https://formulae.brew.sh/formula/bat) or [Homebrew on Linux](https://formulae.brew.sh/formula-linux/bat): @@ -336,7 +363,7 @@ higher. You can then use `cargo` to build everything: cargo install --locked bat ``` -Note that addition files like the man page or shell completion +Note that additional files like the man page or shell completion files can not be installed in this way. They will be generated by `cargo` and should be available in the cargo target folder (under `build`). ## Customization @@ -363,12 +390,11 @@ You can also use a custom theme by following the ### 8-bit themes -`bat` has four themes that always use [8-bit colors](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors), +`bat` has three themes that always use [8-bit colors](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors), even when truecolor support is available: -- `ansi-dark` looks decent on any terminal with a dark background. It uses 3-bit colors: black, red, - green, yellow, blue, magenta, cyan, and white. -- `ansi-light` is like `ansi-dark`, but for terminals with a light background. +- `ansi` looks decent on any terminal. It uses 3-bit colors: black, red, green, + yellow, blue, magenta, cyan, and white. - `base16` is designed for [base16](https://github.com/chriskempson/base16) terminal themes. It uses 4-bit colors (3-bit colors plus bright variants) in accordance with the [base16 styling guidelines](https://github.com/chriskempson/base16/blob/master/styling.md). @@ -391,35 +417,45 @@ variable to make these changes permanent or use `bat`s ### Adding new syntaxes / language definitions +Should you find that a particular syntax is not available within `bat`, you can follow these +instructions to easily add new syntaxes to your current `bat` installation. + `bat` uses the excellent [`syntect`](https://github.com/trishume/syntect/) library for syntax highlighting. `syntect` can read any [Sublime Text `.sublime-syntax` file](https://www.sublimetext.com/docs/3/syntax.html) -and theme. To add new syntax definitions, do the following. +and theme. -Create a folder with syntax definition files: +A good resource for finding Sublime Syntax packages is [Package Control](https://packagecontrol.io/). Once you found a +syntax: -```bash -mkdir -p "$(bat --config-dir)/syntaxes" -cd "$(bat --config-dir)/syntaxes" +1. Create a folder with syntax definition files: -# Put new '.sublime-syntax' language definition files -# in this folder (or its subdirectories), for example: -git clone https://github.com/tellnobody1/sublime-purescript-syntax -``` + ```bash + mkdir -p "$(bat --config-dir)/syntaxes" + cd "$(bat --config-dir)/syntaxes" -Now use the following command to parse these files into a binary cache: + # Put new '.sublime-syntax' language definition files + # in this folder (or its subdirectories), for example: + git clone https://github.com/tellnobody1/sublime-purescript-syntax + ``` -```bash -bat cache --build -``` +2. Now use the following command to parse these files into a binary cache: -Finally, use `bat --list-languages` to check if the new languages are available. + ```bash + bat cache --build + ``` -If you ever want to go back to the default settings, call: +3. Finally, use `bat --list-languages` to check if the new languages are available. -```bash -bat cache --clear -``` + If you ever want to go back to the default settings, call: + + ```bash + bat cache --clear + ``` + +4. If you think that a specific syntax should be included in `bat` by default, please + consider opening a "syntax request" ticket after reading the policies and + instructions [here](doc/assets.md): [Open Syntax Request](https://github.com/sharkdp/bat/issues/new?labels=syntax-request&template=syntax_request.md). ### Adding new themes @@ -439,6 +475,33 @@ bat cache --build Finally, use `bat --list-themes` to check if the new themes are available. +### Adding or changing file type associations + +You can add new (or change existing) file name patterns using the `--map-syntax` +command line option. The option takes an argument of the form `pattern:syntax` where +`pattern` is a glob pattern that is matched against the file name and +the absolute file path. The `syntax` part is the full name of a supported language +(use `bat --list-languages` for an overview)full . + +Note: You probably want to use this option as an entry in `bat`s configuration file instead +of passing it on the command line (see below). + +Example: To use "INI" syntax highlighting for all files with a `.conf` file extension, use +```bash +--map-syntax='*.conf:INI' +``` + +Example: To open all files called `.ignore` (exact match) with the "Git Ignore" syntax, use: +```bash +--map-syntax='.ignore:Git Ignore' +``` + +Example: To open all `.conf` files in subfolders of `/etc/apache2` with the "Apache Conf" +syntax, use (this mapping is already built in): +```bash +-map-syntax='/etc/apache2/**/*.conf:Apache Conf' +``` + ### Using a different pager `bat` uses the pager that is specified in the `PAGER` environment variable. If this variable is not @@ -490,6 +553,7 @@ and the `GitHub` theme when in the _light mode_. alias cat="bat --theme=\$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo default || echo GitHub)" ``` + ## Configuration file `bat` can also be customized with a configuration file. The location of the file is dependent @@ -526,9 +590,6 @@ Example configuration file: # Use C++ syntax for .ino files --map-syntax "*.ino:C++" - -# Use ".gitignore"-style highlighting for ".ignore" files ---map-syntax ".ignore:Git Ignore" ``` ## Using `bat` on Windows @@ -630,6 +691,10 @@ bash assets/create.sh cargo install --path . --locked --force ``` +## Contributing + +Take a look at the [`CONTRIBUTING.md`](CONTRIBUTING.md) guide. + ## Maintainers - [sharkdp](https://github.com/sharkdp) diff --git a/assets/README.md b/assets/README.md deleted file mode 100644 index de4ec1f6..00000000 --- a/assets/README.md +++ /dev/null @@ -1,52 +0,0 @@ -## Syntax Highlighting in bat - -`bat` uses the [syntect](https://github.com/trishume/syntect) library to highlight source -code. As a basis, syntect uses [Sublime Text](https://www.sublimetext.com/) syntax definitions -in the `.sublime-syntax` format. - -In order to add new syntaxes to `bat`, follow these steps: - -1. Find a Sublime Text syntax for the given language, preferably in a separate Git repository - which can be included as a submodule (under `assets/syntaxes`). - -2. If the Sublime Text syntax is only available as a `.tmLanguage` file, open the file in - Sublime Text and convert it to a `.sublime-syntax` file via *Tools* -> *Developer* -> - *New Syntax from XXX.tmLanguage...*. Save the new file in the `assets/syntaxes` folder. - -3. Run the `create.sh` script. It calls `bat cache --build` to parse all available - `.sublime-syntax` files and serialize them to a `syntaxes.bin` file (in this folder). - -4. Re-compile `bat`. At compilation time, the `syntaxes.bin` file will be stored inside the - `bat` binary. - -5. If you send a pull request with your changes, please do *not* include the changed `syntaxes.bin` - file. A new binary cache file will be created once before every new release of `bat`. - -### Troubleshooting - -Make sure that the local cache does not interfere with the internally stored syntaxes and -themes (`bat cache --clear`). - -### Manual modifications - -The following files have been manually modified after converting from a `.tmLanguage` file: - -* `Apache.sublime_syntax`=> removed `.conf` and `.CONF` file types. -* `Dart.sublime-syntax` => removed `#regex.dart` include. -* `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types. -* `Org mode.sublime-syntax` => removed `task` file type. -* `SML.sublime_syntax` => removed `ml` file type. - -### Non-submodule additions - -* `Assembly (x86_64)` has been manually added from https://github.com/13xforever/x86-assembly-textmate-bundle due to `git clone` recursion problems -* `Nim.sublime-syntax` has been added manually from https://github.com/getzola/zola/blob/master/sublime_syntaxes/Nim.sublime-syntax as there was no suitable Git repository for it. The original syntax seems to originate from https://github.com/Varriount/NimLime -* `Rego.sublime-syntax` has been added manually from https://github.com/open-policy-agent/opa/blob/master/misc/syntax/sublime/rego.sublime-syntax - as it is not kept in a standalone repository. The file is generated from - https://github.com/open-policy-agent/opa/blob/master/misc/syntax/textmate/Rego.tmLanguage -* `SML.sublime_syntax` has been added manually from - https://github.com/seanjames777/SML-Language-Definitiona as it is not - kept in a standalone repository. The file generated is from - https://github.com/seanjames777/SML-Language-Definition/blob/master/sml.tmLanguage -* `Cabal.sublime_syntax` has been added manually from - https://github.com/SublimeHaskell/SublimeHaskell/ - we don't want to include the whole submodule because it includes other syntaxes ("Haskell improved") as well. diff --git a/assets/completions/bat.zsh.in b/assets/completions/bat.zsh.in index cef5daaa..edaf7aee 100644 --- a/assets/completions/bat.zsh.in +++ b/assets/completions/bat.zsh.in @@ -3,8 +3,8 @@ local context state state_descr line typeset -A opt_args -(( $+functions[_cache_subcommand] )) || -_cache_subcommand() { +(( $+functions[_{{PROJECT_EXECUTABLE}}_cache_subcommand] )) || +_{{PROJECT_EXECUTABLE}}_cache_subcommand() { local -a args args=( '(-b --build -c --clear)'{-b,--build}'[Initialize or update the syntax/theme cache]' @@ -19,12 +19,12 @@ _cache_subcommand() { _arguments -S -s $args } -(( $+functions[_main] )) || -_main() { +(( $+functions[_{{PROJECT_EXECUTABLE}}_main] )) || +_{{PROJECT_EXECUTABLE}}_main() { local -a args args=( '(-A --show-all)'{-A,--show-all}'[Show non-printable characters (space, tab, newline, ..)]' - {-p,--plain}'[Show plain style (alias for `--style=plain`)]:When `-p` is used twice (`-pp`), it also disables automatic paging (alias for `--style=plain --paging=never`)' + '*'{-p,--plain}'[Show plain style (alias for `--style=plain`), repeat twice to disable disable automatic paging (alias for `--paging=never`)]' '(-l --language)'{-l+,--language=}'[Set the language for syntax highlighting]::->language' '(-H --highlight-line)'{-H,--highlight-line}'[Highlight lines N through M]:...' '(--file-name)'--file-name'[Specify the name to display for a file]:...:_files' @@ -51,13 +51,13 @@ _main() { _arguments -S -s $args - case "$state" in + case "$state" in language) local IFS=$'\n' local -a languages languages=( $({{PROJECT_EXECUTABLE}} --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') ) - _describe 'language' languages + _describe 'language' languages ;; theme) @@ -79,15 +79,15 @@ if (( ${#words} == 2 )); then local -a subcommands subcommands=('cache:Modify the syntax-definition and theme cache') _describe subcommand subcommands - _main + _{{PROJECT_EXECUTABLE}}_main else case $words[2] in cache) - _cache_subcommand + _{{PROJECT_EXECUTABLE}}_cache_subcommand ;; *) - _main + _{{PROJECT_EXECUTABLE}}_main ;; esac fi diff --git a/assets/manual/bat.1.in b/assets/manual/bat.1.in index a6846b5d..65a17fe1 100644 --- a/assets/manual/bat.1.in +++ b/assets/manual/bat.1.in @@ -129,7 +129,7 @@ Configure which elements (line numbers, file headers, grid borders, Git modifica of components to display (e.g. 'numbers,changes,grid') or a pre\-defined style ('full'). To set a default style, add the '\-\-style=".."' option to the configuration file or export the BAT_STYLE environment variable (e.g.: export BAT_STYLE=".."). Possible -values: *auto*, full, plain, changes, header, grid, numbers, snip. +values: *auto*, full, plain, changes, header, grid, rule, numbers, snip. .HP \fB\-r\fR, \fB\-\-line\-range\fR ... .IP diff --git a/assets/patches/ShellScript.sublime-syntax.patch b/assets/patches/ShellScript.sublime-syntax.patch new file mode 100644 index 00000000..4afcdb00 --- /dev/null +++ b/assets/patches/ShellScript.sublime-syntax.patch @@ -0,0 +1,15 @@ +diff --git syntaxes/01_Packages/ShellScript/Bash.sublime-syntax syntaxes/01_Packages/ShellScript/Bash.sublime-syntax +index e973e319..a703cef8 100644 +--- syntaxes/01_Packages/ShellScript/Bash.sublime-syntax ++++ syntaxes/01_Packages/ShellScript/Bash.sublime-syntax +@@ -30,8 +30,8 @@ file_extensions: + - .zshenv + - .zshrc + - PKGBUILD # https://jlk.fjfi.cvut.cz/arch/manpages/man/PKGBUILD.5 +- - .ebuild +- - .eclass ++ - ebuild ++ - eclass + + first_line_match: | + (?x) diff --git a/assets/syntaxes.bin b/assets/syntaxes.bin index a69ec6fe..c1f3051e 100644 Binary files a/assets/syntaxes.bin and b/assets/syntaxes.bin differ diff --git a/assets/syntaxes/02_Extra/AWK b/assets/syntaxes/02_Extra/AWK index e593eb6d..e23926ec 160000 --- a/assets/syntaxes/02_Extra/AWK +++ b/assets/syntaxes/02_Extra/AWK @@ -1 +1 @@ -Subproject commit e593eb6d42a5f1881ba6c75698bd0fb78a9b8871 +Subproject commit e23926eca1b6a0bd0b572b7191aead9f77c748d1 diff --git a/assets/syntaxes/02_Extra/CMake b/assets/syntaxes/02_Extra/CMake index aba96a08..21e96989 160000 --- a/assets/syntaxes/02_Extra/CMake +++ b/assets/syntaxes/02_Extra/CMake @@ -1 +1 @@ -Subproject commit aba96a0862369e9f960bb63a38e2d7563ea6475e +Subproject commit 21e96989d604d64f12d518f4f17fc71fa3cdc505 diff --git a/assets/syntaxes/02_Extra/Elixir b/assets/syntaxes/02_Extra/Elixir index 4ee539b4..4fb01891 160000 --- a/assets/syntaxes/02_Extra/Elixir +++ b/assets/syntaxes/02_Extra/Elixir @@ -1 +1 @@ -Subproject commit 4ee539b43d82388f449535f7316d69f5dfeaabb5 +Subproject commit 4fb01891dd17434dde42887bc821917a30f4e010 diff --git a/assets/syntaxes/02_Extra/GraphQL b/assets/syntaxes/02_Extra/GraphQL index c9d84587..59304d6c 160000 --- a/assets/syntaxes/02_Extra/GraphQL +++ b/assets/syntaxes/02_Extra/GraphQL @@ -1 +1 @@ -Subproject commit c9d84587eb1a6eb34457a875f21b9b1a29306be3 +Subproject commit 59304d6c7b5019091b532a3197251e393e1db7b2 diff --git a/assets/syntaxes/02_Extra/INI.sublime-syntax b/assets/syntaxes/02_Extra/INI.sublime-syntax index 827b7477..4d31bffd 100644 --- a/assets/syntaxes/02_Extra/INI.sublime-syntax +++ b/assets/syntaxes/02_Extra/INI.sublime-syntax @@ -25,12 +25,13 @@ contexts: scope: comment.line.semicolon.ini captures: 1: punctuation.definition.comment.ini - - match: '^\s*(\[)(.*?)(\])' + - match: '^\s*(\[)(.*?)(\])\s*(;.*)?$\n?' scope: meta.tag.section.ini captures: 1: punctuation.definition.section.ini 2: entity.section.ini 3: punctuation.definition.section.ini + 4: comment.definition.section.ini - match: '^(\s*(["'']?)(.+?)(\2)\s*(=))?\s*((["'']?)(.*?)(\7))\s*(;.*)?$\n?' scope: meta.declaration.ini captures: diff --git a/assets/syntaxes/02_Extra/Julia b/assets/syntaxes/02_Extra/Julia index 6c0d770f..e2b1cb54 160000 --- a/assets/syntaxes/02_Extra/Julia +++ b/assets/syntaxes/02_Extra/Julia @@ -1 +1 @@ -Subproject commit 6c0d770fc74e6bc037c70cae1f94fe113b60fd95 +Subproject commit e2b1cb549d57368b7b22e79430a1d5f47555e802 diff --git a/assets/syntaxes/02_Extra/Lean b/assets/syntaxes/02_Extra/Lean new file mode 160000 index 00000000..7e99440b --- /dev/null +++ b/assets/syntaxes/02_Extra/Lean @@ -0,0 +1 @@ +Subproject commit 7e99440b33c834b11deda67144a6a7ce5a666f0e diff --git a/assets/syntaxes/02_Extra/Lean.sublime-syntax b/assets/syntaxes/02_Extra/Lean.sublime-syntax new file mode 100644 index 00000000..55e47cdd --- /dev/null +++ b/assets/syntaxes/02_Extra/Lean.sublime-syntax @@ -0,0 +1,125 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Lean +file_extensions: + - lean +scope: source.lean +contexts: + main: + - include: comments + - match: '\b(?])' + pop: true + - include: comments + - include: definitionName + - match: "," + - match: \b(Prop|Type|Sort)\b + scope: storage.type.lean + - match: '\battribute\b\s*\[[^\]]*\]' + scope: storage.modifier.lean + - match: '@\[[^\]]*\]' + scope: storage.modifier.lean + - match: \b(? diff --git a/assets/syntaxes/02_Extra/Zig b/assets/syntaxes/02_Extra/Zig new file mode 160000 index 00000000..87ecbcae --- /dev/null +++ b/assets/syntaxes/02_Extra/Zig @@ -0,0 +1 @@ +Subproject commit 87ecbcae6fb5718369ce3bb3472ca0b2634e78e6 diff --git a/assets/syntaxes/02_Extra/ssh-config b/assets/syntaxes/02_Extra/ssh-config index 1ddcb320..201816b6 160000 --- a/assets/syntaxes/02_Extra/ssh-config +++ b/assets/syntaxes/02_Extra/ssh-config @@ -1 +1 @@ -Subproject commit 1ddcb320aca1bf31b0048a3109540475d5af64e2 +Subproject commit 201816b609abf7ccf583f7e888f6dc4121410d70 diff --git a/assets/syntaxes/02_Extra/syntax_test_man.man b/assets/syntaxes/02_Extra/syntax_test_man.man new file mode 100644 index 00000000..ee8bada3 --- /dev/null +++ b/assets/syntaxes/02_Extra/syntax_test_man.man @@ -0,0 +1,151 @@ +# SYNTAX TEST "Manpage.sublime-syntax" +SOMETHING(8) System Manager's Manual SOMETHING(8) +# ^^^^^ meta.preprocessor +# ^^^^^^^^^^^^^^^^^^^^^^^ markup.heading.title +# ^^^^^^^ meta.preprocessor + +NAME +#^^^ markup.heading.other + example - do something useful + +SYNOPSIS + example [options] [--home DIR] [--shell SHELL] [--no-create-home] +# ^ punctuation.section.brackets.begin +# ^^^^^^ entity.name.command-line-option +# ^^^ variable.parameter +# ^ punctuation.section.brackets.end +# ^ punctuation.section.brackets.begin +# ^^^^^^^ entity.name.command-line-option +# ^^^^^ variable.parameter +# ^ punctuation.section.brackets.end +# ^ punctuation.section.brackets.begin +# ^^^^^^^^^^^^^^^^ entity.name.command-line-option +# ^ punctuation.section.brackets.end + [-u | --set-upstream] [-o | --push-option=] +# ^ punctuation.section.brackets.begin +# ^^ entity.name.command-line-option +# ^ keyword.operator.logical +# ^^^^^^^^^^^^^^ entity.name.command-line-option +# ^ punctuation.section.brackets.end +# ^^^^^^^^^^^^^ entity.name.command-line-option + [--force-with-lease[=[:]]] +# ^ punctuation.section.brackets.begin +# ^^^^^^^^^^^^^^^^^^ entity.name.command-line-option +# ^ punctuation.section.brackets.begin +# ^ keyword.operator +# ^^^^^^^ variable.parameter +# ^ punctuation.section.brackets.begin +# ^^^^^^ variable.parameter +# ^^^ punctuation.section.brackets.end + + example --system [options] +# ^^^^^^^^ entity.name + + COMMON OPTIONS + [--quiet] [--debug] [--help|-h] [--version] [--conf FILE] + + /* According to POSIX.1-2001, POSIX.1-2008 */ +# ^^ source.c comment.block punctuation.definition.comment + #include +# ^^^^^^^^ source.c meta.preprocessor.include keyword.control.import.include + struct timeval { +# ^^^^^^ source.c storage.type + + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ + }; + + + +DESCRIPTION + example does something useful in relation to the command line options + and configuration information in /etc/example.conf. + +OPTIONS + --conf FILE +# ^^^^^^ entity.name.command-line-option +#^^^^^^ - variable - entity - markup +# ^^^^ variable.parameter + Use FILE instead of /etc/example.conf. +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - variable - entity + + --disabled-login + Do not run passwd to set the password. The user won't be able + to use her account until the password is set. + + --disabled-password + Like --disabled-login, but logins are still possible (for exam- +# ^^^^^^^^^^^^^^^^ entity.name +#^^^^^^^^^^^^^^^^^^ - entity - variable - markup +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - entity - variable - markup + ple using SSH RSA keys) but not using password authentication. + + --help Display brief instructions. +# ^^^^^^ entity.name.command-line-option +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - variable.parameter + + --home DIR +# ^^^^^^ entity.name.command-line-option +# ^^^ variable.parameter +# ^ - variable - entity - markup + Use DIR as the user's home directory, rather than the default + specified by the configuration file. If the directory does not + exist, it is created and skeleton files are copied. + + --[no-]signed, --signed=(true|false|if-asked) +# ^^^^^^^^^^^^^ entity.name.command-line-option +# ^ punctuation.separator +# ^^^^^^^^ entity.name.command-line-option +# ^ keyword.operator +# ^ - variable +# ^^^^ variable.parameter +# ^ keyword.operator.logical +# ^^^^^ variable.parameter +# ^ keyword.operator.logical +# ^^^^^^^^ variable.parameter +# ^ - variable + --no-recurse-submodules, --recurse-submodules=check|on-demand|only|no +# ^^^^^^^^^^^^^^^^^^^^^^^ entity.name.command-line-option +# ^ punctuation.separator +# ^^^^^^^^^^^^^^^^^^^^ entity.name.command-line-option +# ^ keyword.operator +# ^^^^^ variable.parameter +# ^ keyword.operator.logical +# ^^^^^^^^^ variable.parameter +# ^ keyword.operator.logical +# ^^^^ variable.parameter +# ^ keyword.operator.logical +# ^^ variable.parameter + May be used to make sure all submodule commits used by the + + -c, -C NUM, --context[=NUM] +# ^^ entity.name.command-line-option +# ^ punctuation.separator +# ^^ entity.name.command-line-option +# ^^^ variable.parameter +# ^ punctuation.separator +# ^^^^^^^^^ entity.name.command-line-option +# ^^^^^^^ - entity.name +# ^ keyword.operator +# ^^^ variable.parameter +# ^^ - variable + output NUM (default 3) lines of copied context + +EXAMPLE + #include +# ^^^^^^^^ source.c meta.preprocessor.include keyword.control.import.include + + (This is not C code.) +# ^^^^^^^^^^^^^^^^^^^^^^ - source.c + + struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ + }; +# ^ source.c punctuation.terminator + + The corresponding argument for pselect() has the following type: +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - source.c + #define POLLIN_SET (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN | + EPOLLHUP | EPOLLERR) +# ^ source.c meta.preprocessor.macro meta.group punctuation.section.group.end diff --git a/assets/themes.bin b/assets/themes.bin index b8683424..ae04c566 100644 Binary files a/assets/themes.bin and b/assets/themes.bin differ diff --git a/assets/themes/Coldark b/assets/themes/Coldark new file mode 160000 index 00000000..e44750b2 --- /dev/null +++ b/assets/themes/Coldark @@ -0,0 +1 @@ +Subproject commit e44750b2a9629dd12d8ed3ad9fd50c77232170b9 diff --git a/assets/themes/ansi-light.tmTheme b/assets/themes/ansi-light.tmTheme deleted file mode 100644 index 5dfb94e8..00000000 --- a/assets/themes/ansi-light.tmTheme +++ /dev/null @@ -1,504 +0,0 @@ - - - - - - author - Template: Chris Kempson, Scheme: Mitchell Kember - name - ANSI Light - colorSpaceName - sRGB - settings - - - settings - - background - #07000000 - caret - #00000000 - foreground - #00000000 - invisibles - #00000000 - lineHighlight - #00000000 - selection - #00000000 - gutter - #07000000 - gutterForeground - #00000000 - - - - name - Text - scope - variable.parameter.function - settings - - foreground - #00000000 - - - - name - Comments - scope - comment, punctuation.definition.comment - settings - - foreground - #02000000 - - - - name - Punctuation - scope - punctuation.definition.string, punctuation.definition.variable, punctuation.definition.string, punctuation.definition.parameters, punctuation.definition.string, punctuation.definition.array - settings - - foreground - #00000000 - - - - name - Delimiters - scope - none - settings - - foreground - #00000000 - - - - name - Operators - scope - keyword.operator - settings - - foreground - #00000000 - - - - name - Keywords - scope - keyword - settings - - foreground - #05000000 - - - - name - Variables - scope - variable - settings - - foreground - #00000000 - - - - name - Functions - scope - entity.name.function, meta.require, support.function.any-method - settings - - foreground - #04000000 - - - - name - Labels - scope - entity.name.label - settings - - foreground - #06000000 - - - - name - Classes - scope - support.class, entity.name.class, entity.name.type.class - settings - - foreground - #03000000 - - - - name - Classes - scope - meta.class - settings - - foreground - #00000000 - - - - name - Methods - scope - keyword.other.special-method - settings - - foreground - #04000000 - - - - name - Storage - scope - storage - settings - - foreground - #05000000 - - - - name - Support - scope - support.function - settings - - foreground - #06000000 - - - - name - Strings, Inherited Class - scope - string, constant.other.symbol, entity.other.inherited-class - settings - - foreground - #02000000 - - - - name - Integers - scope - constant.numeric - settings - - foreground - #03000000 - - - - name - Floats - scope - none - settings - - foreground - #03000000 - - - - name - Boolean - scope - none - settings - - foreground - #03000000 - - - - name - Constants - scope - constant - settings - - foreground - #03000000 - - - - name - Tags - scope - entity.name.tag - settings - - foreground - #01000000 - - - - name - Attributes - scope - entity.other.attribute-name - settings - - foreground - #03000000 - - - - name - Attribute IDs - scope - entity.other.attribute-name.id, punctuation.definition.entity - settings - - foreground - #04000000 - - - - name - Selector - scope - meta.selector - settings - - foreground - #05000000 - - - - name - Values - scope - none - settings - - foreground - #03000000 - - - - name - Headings - scope - markup.heading punctuation.definition.heading, entity.name.section - settings - - fontStyle - - foreground - #04000000 - - - - name - Units - scope - keyword.other.unit - settings - - foreground - #03000000 - - - - name - Bold - scope - markup.bold, punctuation.definition.bold - settings - - fontStyle - bold - foreground - #03000000 - - - - name - Italic - scope - markup.italic, punctuation.definition.italic - settings - - fontStyle - italic - foreground - #05000000 - - - - name - Code - scope - markup.raw.inline - settings - - foreground - #02000000 - - - - name - Link Text - scope - string.other.link, punctuation.definition.string.end.markdown, punctuation.definition.string.begin.markdown - settings - - foreground - #01000000 - - - - name - Link Url - scope - meta.link - settings - - foreground - #03000000 - - - - name - Quotes - scope - markup.quote - settings - - foreground - #03000000 - - - - name - Inserted - scope - markup.inserted - settings - - foreground - #02000000 - - - - name - Deleted - scope - markup.deleted - settings - - foreground - #01000000 - - - - name - Changed - scope - markup.changed - settings - - foreground - #05000000 - - - - name - Colors - scope - constant.other.color - settings - - foreground - #06000000 - - - - name - Regular Expressions - scope - string.regexp - settings - - foreground - #06000000 - - - - name - Escape Characters - scope - constant.character.escape - settings - - foreground - #06000000 - - - - name - Embedded - scope - punctuation.section.embedded, variable.interpolation - settings - - foreground - #05000000 - - - - name - Illegal - scope - invalid.illegal - settings - - background - #01000000 - foreground - #00000000 - - - - name - Broken - scope - invalid.broken - settings - - background - #03000000 - foreground - #07000000 - - - - uuid - uuid - - diff --git a/assets/themes/ansi-dark.tmTheme b/assets/themes/ansi.tmTheme similarity index 81% rename from assets/themes/ansi-dark.tmTheme rename to assets/themes/ansi.tmTheme index a7976951..957f42bb 100644 --- a/assets/themes/ansi-dark.tmTheme +++ b/assets/themes/ansi.tmTheme @@ -3,14 +3,14 @@ author Template: Chris Kempson, Scheme: Mitchell Kember name - ANSI Dark + ANSI colorSpaceName sRGB settings @@ -19,32 +19,17 @@ settings background - #00000000 - caret - #07000000 + #00000001 foreground - #07000000 - invisibles - #07000000 - lineHighlight - #07000000 - selection - #07000000 + #00000001 + gutter - #00000000 + #00000001 gutterForeground - #07000000 - - - - name - Text - scope - variable.parameter.function - settings - - foreground - #07000000 + #00000001 @@ -58,39 +43,6 @@ #02000000 - - name - Punctuation - scope - punctuation.definition.string, punctuation.definition.variable, punctuation.definition.string, punctuation.definition.parameters, punctuation.definition.string, punctuation.definition.array - settings - - foreground - #07000000 - - - - name - Delimiters - scope - none - settings - - foreground - #07000000 - - - - name - Operators - scope - keyword.operator - settings - - foreground - #07000000 - - name Keywords @@ -102,17 +54,6 @@ #05000000 - - name - Variables - scope - variable - settings - - foreground - #07000000 - - name Functions @@ -146,17 +87,6 @@ #03000000 - - name - Classes - scope - meta.class - settings - - foreground - #07000000 - - name Methods @@ -480,8 +410,6 @@ background #01000000 - foreground - #07000000 @@ -493,8 +421,6 @@ background #03000000 - foreground - #00000000 diff --git a/assets/themes/dracula-sublime b/assets/themes/dracula-sublime index 26c57ec2..c2de0acf 160000 --- a/assets/themes/dracula-sublime +++ b/assets/themes/dracula-sublime @@ -1 +1 @@ -Subproject commit 26c57ec282abcaa76e57e055f38432bd827ac34e +Subproject commit c2de0acf5af67042393cf70de68013153c043656 diff --git a/assets/themes/gruvbox b/assets/themes/gruvbox index e3db74d0..64c47250 160000 --- a/assets/themes/gruvbox +++ b/assets/themes/gruvbox @@ -1 +1 @@ -Subproject commit e3db74d0e5de7bc09cab76377723ccf6bcc64e8c +Subproject commit 64c47250e54298b91e2cf8d401320009aba9f991 diff --git a/assets/themes/onehalf b/assets/themes/onehalf index 3aa42a39..89923117 160000 --- a/assets/themes/onehalf +++ b/assets/themes/onehalf @@ -1 +1 @@ -Subproject commit 3aa42a39ed3cddde0c53976a700b81b8a7067890 +Subproject commit 89923117bc49dd1e0c6b7fdd34bc6dc4d425fe1f diff --git a/assets/themes/zenburn b/assets/themes/zenburn index cb746f69..7f6fb86e 160000 --- a/assets/themes/zenburn +++ b/assets/themes/zenburn @@ -1 +1 @@ -Subproject commit cb746f69624e635f6f4d127fa9244658e690c34b +Subproject commit 7f6fb86e0dcdd06d3c5181ad1cbe94c970834143 diff --git a/diagnostics/info.sh b/diagnostics/info.sh index bf4eb4d8..b8d99983 100755 --- a/diagnostics/info.sh +++ b/diagnostics/info.sh @@ -58,7 +58,8 @@ _bat_:run() { _out "$BAT" --version _out env | grep '^BAT_\|^PAGER=' - local cache_dir="$($BAT --cache-dir)" + local cache_dir + cache_dir="$($BAT --cache-dir)" if [[ -f "${cache_dir}/syntaxes.bin" ]]; then _print_command "$BAT" "--list-languages" echo "Found custom syntax set." @@ -79,8 +80,8 @@ _bat_config_:run() { _bat_wrapper_:run() { _bat_wrapper_:detect_wrapper() { local bat="$1" - if file "$(which "${bat}")" | grep "text executable" &> /dev/null; then - _out_fence cat "$(which "${bat}")" + if file "$(command -v "${bat}")" | grep "text executable" &> /dev/null; then + _out_fence cat "$(command -v "${bat}")" return fi @@ -104,7 +105,8 @@ _bat_wrapper_function_:run() { fi ;; *bash* | *zsh*) - local type="$("$SHELL" --login -i -c "type ${command}" 2>&1)" + local type + type="$("$SHELL" --login -i -c "type ${command}" 2>&1)" if grep 'function' <<< "$type" &> /dev/null; then _out_fence "$SHELL" --login -i -c "declare -f ${command}" return diff --git a/doc/README-ja.md b/doc/README-ja.md index 5491f800..013642cc 100644 --- a/doc/README-ja.md +++ b/doc/README-ja.md @@ -191,7 +191,7 @@ ln -s /usr/bin/batcat ~/.local/bin/bat batの最新リリースを実行する場合、または Ubuntu/Debian の古いバージョンを使用している場合は、[release page](https://github.com/sharkdp/bat/releases) から最新の `.deb` パッケージをダウンロードし、 次の方法でインストールします: ```bash -sudo dpkg -i bat_0.16.0_amd64.deb # adapt version number and architecture +sudo dpkg -i bat_0.17.1_amd64.deb # adapt version number and architecture ``` ### On Alpine Linux diff --git a/doc/README-ko.md b/doc/README-ko.md index 7e64f9f9..95648334 100644 --- a/doc/README-ko.md +++ b/doc/README-ko.md @@ -170,7 +170,7 @@ apt install bat 만약 최근 릴리즈된 bat을 사용을 원하거나 buntu/Debian 예전 버전을 사용하는 경우, [릴리즈 페이지](https://github.com/sharkdp/bat/releases)에서 다음과 같이 `.deb` 패키지를 받아 설치 할 수도 있습니다: ```bash -sudo dpkg -i bat_0.16.0_amd64.deb # adapt version number and architecture +sudo dpkg -i bat_0.17.1_amd64.deb # adapt version number and architecture ``` ### On Alpine Linux diff --git a/doc/README-ru.md b/doc/README-ru.md index dc9dfa56..552fff24 100644 --- a/doc/README-ru.md +++ b/doc/README-ru.md @@ -185,7 +185,7 @@ ln -s /usr/bin/batcat ~/.local/bin/bat [release page](https://github.com/sharkdp/bat/releases) и установить так: ```bash -sudo dpkg -i bat_0.16.0_amd64.deb # измените архитектуру и версию +sudo dpkg -i bat_0.17.1_amd64.deb # измените архитектуру и версию ``` ### Alpine Linux diff --git a/doc/assets.md b/doc/assets.md new file mode 100644 index 00000000..9aa2a87c --- /dev/null +++ b/doc/assets.md @@ -0,0 +1,97 @@ +## Adding new builtin languages for syntax highlighting + +Should you find that a particular syntax is not available within `bat` and think it should be included in `bat` by default, you can follow the instructions outlined below. + +`bat` uses the excellent [syntect](https://github.com/trishume/syntect) library to highlight source +code. As a basis, syntect uses [Sublime Text](https://www.sublimetext.com/) syntax definitions +in the `.sublime-syntax` format. + +**Important:** Before proceeding, verify that the syntax you wish to add meets the [criteria for inclusion](#Criteria-for-inclusion-of-new-syntaxes). + +1. Find a Sublime Text syntax for the given language, preferably in a separate Git repository + which can be included as a submodule (under `assets/syntaxes`). + +2. If the Sublime Text syntax is only available as a `.tmLanguage` file, open the file in + Sublime Text and convert it to a `.sublime-syntax` file via *Tools* -> *Developer* -> + *New Syntax from XXX.tmLanguage...*. Save the new file in the `assets/syntaxes` folder. + +3. Run the `assets/create.sh` script. It calls `bat cache --build` to parse all available + `.sublime-syntax` files and serialize them to a `syntaxes.bin` file. + +4. Re-compile `bat`. At compilation time, the `syntaxes.bin` file will be stored inside the + `bat` binary. + +5. Use `bat --list-languages` to check if the new languages are available. + +6. Add a syntax test for the new language. See [#Syntax-tests](below) for details. + +7. If you send a pull request with your changes, please do *not* include the changed `syntaxes.bin` + file. A new binary cache file will be created once before every new release of `bat`. + +### Syntax tests + +`bat` has a set of syntax highlighting regression tests in `tests/syntax-tests`. The main idea is +make sure that we do not run into issues we had in the past where either (1) syntax highlighting +for some language is suddenly not working anymore or (2) `bat` suddenly crashes for some input (due +to `regex` incompatibilities between `syntect` and Sublime Text). + +In order to add a new test file, please follow these steps (let's take "Ruby" as an example): + +1. Make sure that you are running the **latest version of `bat`** and that `bat` is available on + the path. If you are creating a syntax test for a new builtin syntax (see above), make sure that + your version of `bat` already has the new syntax builtin. +2. Find an example Ruby source file or write one yourself. If possible, the file should aim to be + "comprehensive" (i.e. include a lot of the possible syntax), but this is not strictly necessary. + A simple file is better than none at all. Also, the files shouldn't be gigantic. +3. Save the file in `tests/syntax-tests/source/Ruby` (adapt for your language). The file name could + be `test.rb` (adapt extension) but can also be adapted if that is necessary in order for `bat` to + highlight it correctly (e.g. `Makefile`). +4. If you have copied the file from somewhere else, please make sure that the file *may* be copied + under the respective license and that the license is compatible with `bat`s license. If it + requires attribution, please add a `LICENSE.md` in the same folder with a text like this: + ``` + The `test.rb` file has been added from [enter source here] under the following license: + + [add license text here] + ``` +5. Go to `tests/syntax-tests` and run the `update.sh` Bash script. A new file should be generated + in the `highlighted` folder (e.g. `highlighted/Ruby/test.rb`). +6. Use `cat` or `bat --language=txt` to display the content of this file and make sure that the + syntax highlighting looks correct. +7. `git add` the new files in the `source` folder as well as the autogenerated files in the + `highlighted` folder. + +### Troubleshooting + +Make sure that the local cache does not interfere with the internally stored syntaxes and +themes (`bat cache --clear`). + +## Criteria for inclusion of new syntaxes + +* More than 10,000 downloads on packagecontrol.io/ + +### Manual modifications + +The following files have been manually modified after converting from a `.tmLanguage` file: + +* `Apache.sublime_syntax`=> removed `.conf` and `.CONF` file types. +* `Dart.sublime-syntax` => removed `#regex.dart` include. +* `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types and support for comments after section headers +* `Org mode.sublime-syntax` => removed `task` file type. +* `SML.sublime_syntax` => removed `ml` file type. +* `Robot.sublime_syntax` => changed name to "Robot Framework", added `.resource` extension + +### Non-submodule additions + +* `Assembly (x86_64)` has been manually added from https://github.com/13xforever/x86-assembly-textmate-bundle due to `git clone` recursion problems +* `Nim.sublime-syntax` has been added manually from https://github.com/getzola/zola/blob/master/sublime_syntaxes/Nim.sublime-syntax as there was no suitable Git repository for it. The original syntax seems to originate from https://github.com/Varriount/NimLime +* `Rego.sublime-syntax` has been added manually from https://github.com/open-policy-agent/opa/blob/master/misc/syntax/sublime/rego.sublime-syntax + as it is not kept in a standalone repository. The file is generated from + https://github.com/open-policy-agent/opa/blob/master/misc/syntax/textmate/Rego.tmLanguage +* `SML.sublime_syntax` has been added manually from + https://github.com/seanjames777/SML-Language-Definitiona as it is not + kept in a standalone repository. The file generated is from + https://github.com/seanjames777/SML-Language-Definition/blob/master/sml.tmLanguage +* `Cabal.sublime_syntax` has been added manually from + https://github.com/SublimeHaskell/SublimeHaskell/ - we don't want to include the whole submodule because it includes other syntaxes ("Haskell improved") as well. +* `Lean.sublime-syntax` has been added manually from https://github.com/leanprover/vscode-lean/blob/master/syntaxes/lean.json via conversion. diff --git a/doc/logo-header.svg b/doc/logo-header.svg index 17830b84..b29b2e7f 100644 --- a/doc/logo-header.svg +++ b/doc/logo-header.svg @@ -45,7 +45,7 @@ showguides="true" inkscape:guide-bbox="true" /> theme, None => { + if theme == "ansi-light" || theme == "ansi-dark" { + bat_warning!("Theme '{}' is deprecated, using 'ansi' instead.", theme); + return self.get_theme("ansi"); + } if theme != "" { - use ansi_term::Colour::Yellow; - eprintln!( - "{}: Unknown theme '{}', using default.", - Yellow.paint("[bat warning]"), - theme - ); + bat_warning!("Unknown theme '{}', using default.", theme) } &self.theme_set.themes[self.fallback_theme.unwrap_or_else(|| Self::default_theme())] } diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index 8249e3c9..3d0df0ec 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -16,6 +16,7 @@ use console::Term; use crate::input::{new_file_input, new_stdin_input}; use bat::{ assets::HighlightingAssets, + bat_warning, config::{Config, VisibleLines}, error::*, input::Input, @@ -82,10 +83,9 @@ impl App { Some("always") => PagingMode::Always, Some("never") => PagingMode::Never, Some("auto") | None => { - if self.matches.occurrences_of("plain") > 1 { - // If we have -pp as an option when in auto mode, the pager should be disabled. - PagingMode::Never - } else if self.matches.is_present("no-paging") { + // If we have -pp as an option when in auto mode, the pager should be disabled. + let extra_plain = self.matches.occurrences_of("plain") > 1; + if extra_plain || self.matches.is_present("no-paging") { PagingMode::Never } else if inputs.iter().any(Input::is_stdin) { // If we are reading from stdin, only enable paging if we write to an @@ -169,9 +169,8 @@ impl App { || match self.matches.value_of("color") { Some("always") => true, Some("never") => false, - Some("auto") | _ => { - env::var_os("NO_COLOR").is_none() && self.interactive_output - } + Some("auto") => env::var_os("NO_COLOR").is_none() && self.interactive_output, + _ => unreachable!("other values for --color are not allowed"), }, paging_mode, term_width: maybe_term_width.unwrap_or(Term::stdout().size().1 as usize), @@ -226,17 +225,14 @@ impl App { style_components, syntax_mapping, pager: self.matches.value_of("pager"), - use_italic_text: match self.matches.value_of("italic-text") { - Some("always") => true, - _ => false, - }, + use_italic_text: self.matches.value_of("italic-text") == Some("always"), highlighted_lines: self .matches .values_of("highlight-line") .map(|ws| ws.map(LineRange::from).collect()) .transpose()? .map(LineRanges::from) - .map(|lr| HighlightedLineRanges(lr)) + .map(HighlightedLineRanges) .unwrap_or_default(), }) } @@ -288,8 +284,8 @@ impl App { fn style_components(&self) -> Result { let matches = &self.matches; - Ok(StyleComponents( - if matches.value_of("decorations") == Some("never") { + let mut styled_components = + StyleComponents(if matches.value_of("decorations") == Some("never") { HashSet::new() } else if matches.is_present("number") { [StyleComponent::LineNumbers].iter().cloned().collect() @@ -323,7 +319,13 @@ impl App { acc.extend(components.iter().cloned()); acc }) - }, - )) + }); + + // If `grid` is set, remove `rule` as it is a subset of `grid`, and print a warning. + if styled_components.grid() && styled_components.0.remove(&StyleComponent::Rule) { + bat_warning!("Style 'rule' is a subset of style 'grid', 'rule' will not be visible."); + } + + Ok(styled_components) } } diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index d04abd8a..4e642760 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -367,7 +367,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { .validator(|val| { let mut invalid_vals = val.split(',').filter(|style| { !&[ - "auto", "full", "plain", "header", "grid", "numbers", "snip", + "auto", "full", "plain", "header", "grid", "rule", "numbers", "snip", #[cfg(feature = "git")] "changes", ] @@ -382,7 +382,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { }) .help( "Comma-separated list of style elements to display \ - (*auto*, full, plain, changes, header, grid, numbers, snip).", + (*auto*, full, plain, changes, header, grid, rule, numbers, snip).", ) .long_help( "Configure which elements (line numbers, file headers, grid \ @@ -400,6 +400,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { * header: show filenames before the content.\n \ * grid: vertical/horizontal lines to separate side bar\n \ and the header from the content.\n \ + * rule: horizontal lines to delimit files.\n \ * numbers: show line numbers in the side bar.\n \ * snip: draw separation lines between distinct line ranges.", ), diff --git a/src/bin/bat/config.rs b/src/bin/bat/config.rs index c7ce08d5..e7ede5a3 100644 --- a/src/bin/bat/config.rs +++ b/src/bin/bat/config.rs @@ -44,8 +44,7 @@ pub fn generate_config_file() -> bat::error::Result<()> { } } - let default_config = - r#"# This is `bat`s configuration file. Each line either contains a comment or + let default_config = r#"# This is `bat`s configuration file. Each line either contains a comment or # a command-line option that you want to pass to `bat` by default. You can # run `bat --help` to get a list of all possible configuration options. @@ -86,7 +85,7 @@ pub fn get_args_from_config_file() -> Result, shell_words::ParseEr .ok() .map(|content| get_args_from_str(&content)) .transpose()? - .unwrap_or_else(|| vec![])) + .unwrap_or_else(Vec::new)) } pub fn get_args_from_env_var() -> Option, shell_words::ParseError>> { diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs index 50c39371..af8ca787 100644 --- a/src/bin/bat/main.rs +++ b/src/bin/bat/main.rs @@ -36,6 +36,7 @@ use bat::{ input::Input, style::{StyleComponent, StyleComponents}, MappingTarget, + PagingMode, }; const THEME_PREVIEW_DATA: &[u8] = include_bytes!("../../../assets/theme_preview.rs"); @@ -78,7 +79,9 @@ fn get_syntax_mapping_to_paths<'a>( map } -pub fn list_languages(config: &Config) -> Result<()> { +pub fn get_languages(config: &Config) -> Result { + let mut result: String = String::new(); + let assets = assets_from_cache_or_binary()?; let mut languages = assets .syntaxes() @@ -119,12 +122,9 @@ pub fn list_languages(config: &Config) -> Result<()> { } } - let stdout = io::stdout(); - let mut stdout = stdout.lock(); - if config.loop_through { for lang in languages { - writeln!(stdout, "{}:{}", lang.name, lang.file_extensions.join(","))?; + result += &format!("{}:{}\n", lang.name, lang.file_extensions.join(",")); } } else { let longest = languages @@ -145,7 +145,7 @@ pub fn list_languages(config: &Config) -> Result<()> { }; for lang in languages { - write!(stdout, "{:width$}{}", lang.name, separator, width = longest)?; + result += &format!("{:width$}{}", lang.name, separator, width = longest); // Number of characters on this line so far, wrap before `desired_width` let mut num_chars = 0; @@ -156,20 +156,20 @@ pub fn list_languages(config: &Config) -> Result<()> { let new_chars = word.len() + comma_separator.len(); if num_chars + new_chars >= desired_width { num_chars = 0; - write!(stdout, "\n{:width$}{}", "", separator, width = longest)?; + result += &format!("\n{:width$}{}", "", separator, width = longest); } num_chars += new_chars; - write!(stdout, "{}", style.paint(&word[..]))?; + result += &format!("{}", style.paint(&word[..])); if extension.peek().is_some() { - write!(stdout, "{}", comma_separator)?; + result += comma_separator; } } - writeln!(stdout)?; + result += "\n"; } } - Ok(()) + Ok(result) } fn theme_preview_file<'a>() -> Input<'a> { @@ -200,6 +200,14 @@ pub fn list_themes(cfg: &Config) -> Result<()> { .ok(); writeln!(stdout)?; } + writeln!( + stdout, + "Further themes can be installed to '{}', \ + and are added to the cache with `bat cache --build`. \ + For more information, see:\n\n \ + https://github.com/sharkdp/bat#adding-new-themes", + config_file().join("themes").to_string_lossy() + )?; } else { for theme in assets.themes() { writeln!(stdout, "{}", theme)?; @@ -240,8 +248,14 @@ fn run() -> Result { let config = app.config(&inputs)?; if app.matches.is_present("list-languages") { - list_languages(&config)?; - Ok(true) + let languages: String = get_languages(&config)?; + let inputs: Vec = vec![Input::from_reader(Box::new(languages.as_bytes()))]; + let plain_config = Config { + style_components: StyleComponents::new(StyleComponent::Plain.components(false)), + paging_mode: PagingMode::QuitIfOneScreen, + ..Default::default() + }; + run_controller(inputs, &plain_config) } else if app.matches.is_present("list-themes") { list_themes(&config)?; Ok(true) diff --git a/src/controller.rs b/src/controller.rs index 3fe44a72..8dd73986 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -54,7 +54,10 @@ impl<'b> Controller<'b> { paging_mode = PagingMode::Never; } } - output_type = OutputType::from_mode(paging_mode, self.config.pager)?; + + let wrapping_mode = self.config.wrapping_mode; + + output_type = OutputType::from_mode(paging_mode, wrapping_mode, self.config.pager)?; } #[cfg(not(feature = "paging"))] @@ -144,7 +147,7 @@ impl<'b> Controller<'b> { Ok(no_errors) } - fn print_file<'a>( + fn print_file( &self, printer: &mut dyn Printer, writer: &mut dyn Write, @@ -194,6 +197,8 @@ impl<'b> Controller<'b> { let mut first_range: bool = true; let mut mid_range: bool = false; + let style_snip = self.config.style_components.snip(); + while reader.read_line(&mut line_buffer)? { match line_ranges.check(line_number) { RangeCheckResult::BeforeOrBetweenRanges => { @@ -204,7 +209,7 @@ impl<'b> Controller<'b> { } RangeCheckResult::InRange => { - if self.config.style_components.snip() { + if style_snip { if first_range { first_range = false; mid_range = true; diff --git a/src/error.rs b/src/error.rs index 2e73b85b..3e5b3711 100644 --- a/src/error.rs +++ b/src/error.rs @@ -20,6 +20,10 @@ error_chain! { description("unknown syntax"), display("unknown syntax: '{}'", name) } + InvalidPagerValueBat { + description("invalid value `bat` for pager property"), + display("Use of bat as a pager is disallowed in order to avoid infinite recursion problems") + } } } diff --git a/src/input.rs b/src/input.rs index b4b058e2..5d8493c0 100644 --- a/src/input.rs +++ b/src/input.rs @@ -143,9 +143,8 @@ impl<'a> Input<'a> { } pub fn with_name(mut self, provided_name: Option<&OsStr>) -> Self { - match provided_name { - Some(name) => self.description.name = name.to_string_lossy().to_string(), - None => {} + if let Some(name) = provided_name { + self.description.name = name.to_string_lossy().to_string() } self.metadata.user_provided_name = provided_name.map(|n| n.to_owned()); diff --git a/src/lib.rs b/src/lib.rs index 6d6dd206..d0d1fe0c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,6 +19,8 @@ //! .unwrap(); //! ``` +mod macros; + pub mod assets; pub mod assets_metadata; pub mod config; diff --git a/src/macros.rs b/src/macros.rs new file mode 100644 index 00000000..beb63ea7 --- /dev/null +++ b/src/macros.rs @@ -0,0 +1,7 @@ +#[macro_export] +macro_rules! bat_warning { + ($($arg:tt)*) => ({ + use ansi_term::Colour::Yellow; + eprintln!("{}: {}", Yellow.paint("[bat warning]"), format!($($arg)*)); + }) +} diff --git a/src/output.rs b/src/output.rs index e7d59d67..689371b9 100644 --- a/src/output.rs +++ b/src/output.rs @@ -7,6 +7,15 @@ use crate::error::*; use crate::less::retrieve_less_version; #[cfg(feature = "paging")] use crate::paging::PagingMode; +#[cfg(feature = "paging")] +use crate::wrapping::WrappingMode; + +#[cfg(feature = "paging")] +#[derive(Debug, PartialEq)] +enum SingleScreenAction { + Quit, + Nothing, +} #[derive(Debug)] pub enum OutputType { @@ -17,18 +26,28 @@ pub enum OutputType { impl OutputType { #[cfg(feature = "paging")] - pub fn from_mode(mode: PagingMode, pager: Option<&str>) -> Result { + pub fn from_mode( + paging_mode: PagingMode, + wrapping_mode: WrappingMode, + pager: Option<&str>, + ) -> Result { use self::PagingMode::*; - Ok(match mode { - Always => OutputType::try_pager(false, pager)?, - QuitIfOneScreen => OutputType::try_pager(true, pager)?, + Ok(match paging_mode { + Always => OutputType::try_pager(SingleScreenAction::Nothing, wrapping_mode, pager)?, + QuitIfOneScreen => { + OutputType::try_pager(SingleScreenAction::Quit, wrapping_mode, pager)? + } _ => OutputType::stdout(), }) } /// Try to launch the pager. Fall back to stdout in case of errors. #[cfg(feature = "paging")] - fn try_pager(quit_if_one_screen: bool, pager_from_config: Option<&str>) -> Result { + fn try_pager( + single_screen_action: SingleScreenAction, + wrapping_mode: WrappingMode, + pager_from_config: Option<&str>, + ) -> Result { use std::env; use std::ffi::OsString; use std::path::PathBuf; @@ -66,10 +85,10 @@ impl OutputType { match pagerflags.split_first() { Some((pager_name, args)) => { - let mut pager_path = PathBuf::from(pager_name); + let pager_path = PathBuf::from(pager_name); if pager_path.file_stem() == Some(&OsString::from("bat")) { - pager_path = PathBuf::from("less"); + return Err(ErrorKind::InvalidPagerValueBat.into()); } let is_less = pager_path.file_stem() == Some(&OsString::from("less")); @@ -78,10 +97,14 @@ impl OutputType { let mut p = Command::new(&pager_path); if args.is_empty() || replace_arguments_to_less { p.arg("--RAW-CONTROL-CHARS"); - if quit_if_one_screen { + if single_screen_action == SingleScreenAction::Quit { p.arg("--quit-if-one-screen"); } + if wrapping_mode == WrappingMode::NoWrapping { + p.arg("--chop-long-lines"); + } + // Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older // versions of 'less'. Unfortunately, it also breaks mouse-wheel support. // diff --git a/src/preprocessor.rs b/src/preprocessor.rs index eb878890..7001ec88 100644 --- a/src/preprocessor.rs +++ b/src/preprocessor.rs @@ -72,7 +72,7 @@ pub fn replace_nonprintable(input: &[u8], tab_width: usize) -> String { } } // line feed - '\x0A' => output.push('␊'), + '\x0A' => output.push_str("␊\x0A"), // carriage return '\x0D' => output.push('␍'), // null diff --git a/src/pretty_printer.rs b/src/pretty_printer.rs index c9530bf4..cdf22df9 100644 --- a/src/pretty_printer.rs +++ b/src/pretty_printer.rs @@ -23,6 +23,7 @@ struct ActiveStyleComponents { header: bool, vcs_modification_markers: bool, grid: bool, + rule: bool, line_numbers: bool, snip: bool, } @@ -179,6 +180,12 @@ impl<'a> PrettyPrinter<'a> { self } + /// Whether to paint a horizontal rule to delimit files + pub fn rule(&mut self, yes: bool) -> &mut Self { + self.active_style_components.rule = yes; + self + } + /// Whether to show modification markers for VCS changes. This has no effect if /// the `git` feature is not activated. #[cfg_attr( @@ -285,6 +292,9 @@ impl<'a> PrettyPrinter<'a> { if self.active_style_components.grid { style_components.push(StyleComponent::Grid); } + if self.active_style_components.rule { + style_components.push(StyleComponent::Rule); + } if self.active_style_components.header { style_components.push(StyleComponent::Header); } @@ -328,7 +338,7 @@ impl<'a> Input<'a> { /// A new input from bytes. pub fn from_bytes(bytes: &'a [u8]) -> Self { - Input::from_reader(bytes).into() + Input::from_reader(bytes) } /// A new input from STDIN. diff --git a/src/printer.rs b/src/printer.rs index 71bf78ee..a4b143d4 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -91,9 +91,6 @@ impl<'a> Printer for SimplePrinter<'a> { if self.config.show_nonprintable { let line = replace_nonprintable(line_buffer, self.config.tab_width); write!(handle, "{}", line)?; - if line_buffer.last() == Some(&b'\n') { - writeln!(handle)?; - } } else { handle.write_all(line_buffer)? }; @@ -200,13 +197,18 @@ impl<'a> InteractivePrinter<'a> { }) } + fn print_horizontal_line_term(&mut self, handle: &mut dyn Write, style: Style) -> Result<()> { + writeln!( + handle, + "{}", + style.paint("─".repeat(self.config.term_width)) + )?; + Ok(()) + } + fn print_horizontal_line(&mut self, handle: &mut dyn Write, grid_char: char) -> Result<()> { if self.panel_width == 0 { - writeln!( - handle, - "{}", - self.colors.grid.paint("─".repeat(self.config.term_width)) - )?; + self.print_horizontal_line_term(handle, self.colors.grid)?; } else { let hline = "─".repeat(self.config.term_width - (self.panel_width + 1)); let hline = format!("{}{}{}", "─".repeat(self.panel_width), grid_char, hline); @@ -251,6 +253,10 @@ impl<'a> Printer for InteractivePrinter<'a> { input: &OpenedInput, add_header_padding: bool, ) -> Result<()> { + if add_header_padding && self.config.style_components.rule() { + self.print_horizontal_line_term(handle, self.colors.rule)?; + } + if !self.config.style_components.header() { if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable { writeln!( @@ -279,7 +285,8 @@ impl<'a> Printer for InteractivePrinter<'a> { .paint(if self.panel_width > 0 { "│ " } else { "" }), )?; } else { - if add_header_padding { + // Only pad space between files, if we haven't already drawn a horizontal rule + if add_header_padding && !self.config.style_components.rule() { writeln!(handle)?; } write!(handle, "{}", " ".repeat(self.panel_width))?; @@ -301,7 +308,7 @@ impl<'a> Printer for InteractivePrinter<'a> { description .kind() .map(|kind| format!("{}: ", kind)) - .unwrap_or("".into()), + .unwrap_or_else(|| "".into()), self.colors.filename.paint(description.title()), mode )?; @@ -441,7 +448,7 @@ impl<'a> Printer for InteractivePrinter<'a> { if text.len() != text_trimmed.len() { if let Some(background_color) = background_color { let mut ansi_style = Style::default(); - ansi_style.background = Some(to_ansi_color(background_color, true_color)); + ansi_style.background = to_ansi_color(background_color, true_color); let width = if cursor_total <= cursor_max { cursor_max - cursor_total + 1 } else { @@ -453,7 +460,7 @@ impl<'a> Printer for InteractivePrinter<'a> { } } - if line.bytes().next_back() != Some(b'\n') { + if !self.config.style_components.plain() && line.bytes().next_back() != Some(b'\n') { writeln!(handle)?; } } else { @@ -582,8 +589,7 @@ impl<'a> Printer for InteractivePrinter<'a> { if let Some(background_color) = background_color { let mut ansi_style = Style::default(); - ansi_style.background = - Some(to_ansi_color(background_color, self.config.true_color)); + ansi_style.background = to_ansi_color(background_color, self.config.true_color); write!( handle, @@ -603,6 +609,7 @@ const DEFAULT_GUTTER_COLOR: u8 = 238; #[derive(Debug, Default)] pub struct Colors { pub grid: Style, + pub rule: Style, pub filename: Style, pub git_added: Style, pub git_removed: Style, @@ -616,19 +623,27 @@ impl Colors { } fn colored(theme: &Theme, true_color: bool) -> Self { - let gutter_color = theme - .settings - .gutter_foreground - .map(|c| to_ansi_color(c, true_color)) - .unwrap_or(Fixed(DEFAULT_GUTTER_COLOR)); + let gutter_style = Style { + foreground: match theme.settings.gutter_foreground { + // If the theme provides a gutter foreground color, use it. + // Note: It might be the special value #00000001, in which case + // to_ansi_color returns None and we use an empty Style + // (resulting in the terminal's default foreground color). + Some(c) => to_ansi_color(c, true_color), + // Otherwise, use a specific fallback color. + None => Some(Fixed(DEFAULT_GUTTER_COLOR)), + }, + ..Style::default() + }; Colors { - grid: gutter_color.normal(), + grid: gutter_style, + rule: gutter_style, filename: Style::new().bold(), git_added: Green.normal(), git_removed: Red.normal(), git_modified: Yellow.normal(), - line_number: gutter_color.normal(), + line_number: gutter_style, } } } diff --git a/src/style.rs b/src/style.rs index 8d51cbde..65414206 100644 --- a/src/style.rs +++ b/src/style.rs @@ -9,6 +9,7 @@ pub enum StyleComponent { #[cfg(feature = "git")] Changes, Grid, + Rule, Header, LineNumbers, Snip, @@ -29,6 +30,7 @@ impl StyleComponent { #[cfg(feature = "git")] StyleComponent::Changes => &[StyleComponent::Changes], StyleComponent::Grid => &[StyleComponent::Grid], + StyleComponent::Rule => &[StyleComponent::Rule], StyleComponent::Header => &[StyleComponent::Header], StyleComponent::LineNumbers => &[StyleComponent::LineNumbers], StyleComponent::Snip => &[StyleComponent::Snip], @@ -54,6 +56,7 @@ impl FromStr for StyleComponent { #[cfg(feature = "git")] "changes" => Ok(StyleComponent::Changes), "grid" => Ok(StyleComponent::Grid), + "rule" => Ok(StyleComponent::Rule), "header" => Ok(StyleComponent::Header), "numbers" => Ok(StyleComponent::LineNumbers), "snip" => Ok(StyleComponent::Snip), @@ -81,6 +84,10 @@ impl StyleComponents { self.0.contains(&StyleComponent::Grid) } + pub fn rule(&self) -> bool { + self.0.contains(&StyleComponent::Rule) + } + pub fn header(&self) -> bool { self.0.contains(&StyleComponent::Header) } diff --git a/src/terminal.rs b/src/terminal.rs index b744ba9a..b7159347 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -3,13 +3,13 @@ use ansi_term::{self, Style}; use syntect::highlighting::{self, FontStyle}; -pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term::Color { +pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> Option { if color.a == 0 { // Themes can specify one of the user-configurable terminal colors by // encoding them as #RRGGBBAA with AA set to 00 (transparent) and RR set - // to the 8-bit color palette number. The built-in themes ansi-light, - // ansi-dark, base16, and base16-256 use this. - match color.r { + // to the 8-bit color palette number. The built-in themes ansi, base16, + // and base16-256 use this. + Some(match color.r { // For the first 8 colors, use the Color enum to produce ANSI escape // sequences using codes 30-37 (foreground) and 40-47 (background). // For example, red foreground is \x1b[31m. This works on terminals @@ -31,11 +31,18 @@ pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term: // 90-97 (foreground) and 100-107 (background), we should use those // for values 0x08 to 0x0f and only use Fixed for 0x10 to 0xff. n => Fixed(n), - } + }) + } else if color.a == 1 { + // Themes can specify the terminal's default foreground/background color + // (i.e. no escape sequence) using the encoding #RRGGBBAA with AA set to + // 01. The built-in theme ansi uses this. + None } else if true_color { - RGB(color.r, color.g, color.b) + Some(RGB(color.r, color.g, color.b)) } else { - Fixed(ansi_colours::ansi256_from_rgb((color.r, color.g, color.b))) + Some(Fixed(ansi_colours::ansi256_from_rgb(( + color.r, color.g, color.b, + )))) } } @@ -54,7 +61,10 @@ pub fn as_terminal_escaped( let mut style = if !colored { Style::default() } else { - let mut color = Style::from(to_ansi_color(style.foreground, true_color)); + let mut color = Style { + foreground: to_ansi_color(style.foreground, true_color), + ..Style::default() + }; if style.font_style.contains(FontStyle::BOLD) { color = color.bold(); } @@ -67,6 +77,6 @@ pub fn as_terminal_escaped( color }; - style.background = background_color.map(|c| to_ansi_color(c, true_color)); + style.background = background_color.and_then(|c| to_ansi_color(c, true_color)); style.paint(text).to_string() } diff --git a/tests/.gitattributes b/tests/.gitattributes index 5e4f025b..cd9cbfc3 100644 --- a/tests/.gitattributes +++ b/tests/.gitattributes @@ -4,10 +4,6 @@ snapshots/** text=auto eol=lf syntax-tests/source/** text=auto eol=lf syntax-tests/highlighted/** text=auto eol=lf -# BAT/CMD files always need CRLF EOLs -*.[Bb][Aa][Tt] text eol=crlf -*.[Cc][Mm][Dd] text eol=crlf - examples/* linguist-vendored snapshots/* linguist-vendored benchmarks/* linguist-vendored diff --git a/tests/assets.rs b/tests/assets.rs index 7ced769c..d5de9015 100644 --- a/tests/assets.rs +++ b/tests/assets.rs @@ -1,7 +1,9 @@ use bat::assets::HighlightingAssets; /// This test ensures that we are not accidentally removing themes due to submodule updates. +/// It is 'ignore'd by default because it requires themes.bin to be up-to-date. #[test] +#[ignore] fn all_themes_are_present() { let assets = HighlightingAssets::from_binary(); @@ -12,6 +14,8 @@ fn all_themes_are_present() { themes, vec![ "1337", + "Coldark-Cold", + "Coldark-Dark", "DarkNeon", "Dracula", "GitHub", @@ -26,13 +30,11 @@ fn all_themes_are_present() { "Solarized (light)", "Sublime Snazzy", "TwoDark", - "ansi-dark", - "ansi-light", + "ansi", "base16", "base16-256", - "gruvbox", + "gruvbox-dark", "gruvbox-light", - "gruvbox-white", "zenburn" ] ); diff --git a/tests/benchmarks/comparison.sh b/tests/benchmarks/comparison.sh index c9eb5237..be1479e6 100755 --- a/tests/benchmarks/comparison.sh +++ b/tests/benchmarks/comparison.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash -cd "$(dirname "${BASH_SOURCE[0]}")" +cd "$(dirname "${BASH_SOURCE[0]}")" || exit -if ! which hyperfine > /dev/null 2>&1; then +if ! command -v hyperfine > /dev/null 2>&1; then echo "'hyperfine' does not seem to be installed." echo "You can get it here: https://github.com/sharkdp/hyperfine" exit 1 diff --git a/tests/benchmarks/run-benchmarks.sh b/tests/benchmarks/run-benchmarks.sh index c7f96b4a..86f4bf68 100755 --- a/tests/benchmarks/run-benchmarks.sh +++ b/tests/benchmarks/run-benchmarks.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash -cd "$(dirname "${BASH_SOURCE[0]}")" +cd "$(dirname "${BASH_SOURCE[0]}")" || exit # Check that Hyperfine is installed. -if ! which hyperfine > /dev/null 2>&1; then - echo "'hyperfine' does not seem to be installed." 1>&2 - echo "You can get it here: https://github.com/sharkdp/hyperfine" 1>&2 +if ! command -v hyperfine > /dev/null 2>&1; then + echo "'hyperfine' does not seem to be installed." + echo "You can get it here: https://github.com/sharkdp/hyperfine" exit 1 fi diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index da0690ef..3373aa7d 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -405,6 +405,16 @@ fn pager_disable() { .stdout(predicate::eq("hello world\n").normalize()); } +#[test] +fn pager_value_bat() { + bat() + .arg("--pager=bat") + .arg("--paging=always") + .arg("test.txt") + .assert() + .failure(); +} + #[test] fn alias_pager_disable() { bat() @@ -570,6 +580,18 @@ fn empty_file_leads_to_empty_output_with_grid_enabled() { .stdout(""); } +#[test] +fn empty_file_leads_to_empty_output_with_rule_enabled() { + bat() + .arg("empty.txt") + .arg("--style=rule") + .arg("--decorations=always") + .arg("--terminal-width=80") + .assert() + .success() + .stdout(""); +} + #[test] fn filename_basic() { bat() @@ -668,6 +690,48 @@ fn header_padding() { .stderr(""); } +#[test] +fn header_padding_rule() { + bat() + .arg("--decorations=always") + .arg("--style=header,rule") + .arg("--terminal-width=80") + .arg("test.txt") + .arg("single-line.txt") + .assert() + .stdout( + "File: test.txt +hello world +──────────────────────────────────────────────────────────────────────────────── +File: single-line.txt +Single Line +", + ) + .stderr(""); +} + +#[test] +fn grid_overrides_rule() { + bat() + .arg("--decorations=always") + .arg("--style=grid,rule") + .arg("--terminal-width=80") + .arg("test.txt") + .arg("single-line.txt") + .assert() + .stdout( + "\ +──────────────────────────────────────────────────────────────────────────────── +hello world +──────────────────────────────────────────────────────────────────────────────── +──────────────────────────────────────────────────────────────────────────────── +Single Line +──────────────────────────────────────────────────────────────────────────────── +", + ) + .stderr("\x1b[33m[bat warning]\x1b[0m: Style 'rule' is a subset of style 'grid', 'rule' will not be visible.\n"); +} + #[cfg(target_os = "linux")] #[test] fn file_with_invalid_utf8_filename() { @@ -749,3 +813,41 @@ fn show_all_mode() { .stdout("hello·world␊\n├──┤␍␀␇␈␛") .stderr(""); } + +#[test] +fn plain_mode_does_not_add_nonexisting_newline() { + bat() + .arg("--paging=never") + .arg("--color=never") + .arg("--decorations=always") + .arg("--style=plain") + .arg("single-line.txt") + .assert() + .success() + .stdout("Single Line"); +} + +// Regression test for https://github.com/sharkdp/bat/issues/299 +#[test] +fn grid_for_file_without_newline() { + bat() + .arg("--paging=never") + .arg("--color=never") + .arg("--terminal-width=80") + .arg("--wrap=never") + .arg("--decorations=always") + .arg("--style=full") + .arg("single-line.txt") + .assert() + .success() + .stdout( + "\ +───────┬──────────────────────────────────────────────────────────────────────── + │ File: single-line.txt +───────┼──────────────────────────────────────────────────────────────────────── + 1 │ Single Line +───────┴──────────────────────────────────────────────────────────────────────── +", + ) + .stderr(""); +} diff --git a/tests/snapshot_tests.rs b/tests/snapshot_tests.rs index ad41edb2..8abb8414 100644 --- a/tests/snapshot_tests.rs +++ b/tests/snapshot_tests.rs @@ -19,17 +19,27 @@ snapshot_tests! { grid: "grid", header: "header", numbers: "numbers", + rule: "rule", changes_grid: "changes,grid", changes_header: "changes,header", changes_numbers: "changes,numbers", + changes_rule: "changes,rule", grid_header: "grid,header", grid_numbers: "grid,numbers", + grid_rule: "grid,rule", header_numbers: "header,numbers", + header_rule: "header,rule", changes_grid_header: "changes,grid,header", changes_grid_numbers: "changes,grid,numbers", + changes_grid_rule: "changes,grid,rule", changes_header_numbers: "changes,header,numbers", + changes_header_rule: "changes,header,rule", grid_header_numbers: "grid,header,numbers", + grid_header_rule: "grid,header,rule", + header_numbers_rule: "header,numbers,rule", changes_grid_header_numbers: "changes,grid,header,numbers", + changes_grid_header_rule: "changes,grid,header,rule", + changes_grid_header_numbers_rule: "changes,grid,header,numbers,rule", full: "full", plain: "plain", } diff --git a/tests/snapshots/generate_snapshots.py b/tests/snapshots/generate_snapshots.py index fd17b285..bb7d69ba 100755 --- a/tests/snapshots/generate_snapshots.py +++ b/tests/snapshots/generate_snapshots.py @@ -7,7 +7,7 @@ import shutil def generate_snapshots(): - single_styles = ["changes", "grid", "header", "numbers"] + single_styles = ["changes", "grid", "header", "numbers", "rule"] collective_styles = ["full", "plain"] for num in range(len(single_styles)): diff --git a/tests/snapshots/output/changes_grid_header_numbers_rule.snapshot.txt b/tests/snapshots/output/changes_grid_header_numbers_rule.snapshot.txt new file mode 100644 index 00000000..cee4737f --- /dev/null +++ b/tests/snapshots/output/changes_grid_header_numbers_rule.snapshot.txt @@ -0,0 +1,26 @@ +───────┬──────────────────────────────────────────────────────────────────────── + │ File: sample.rs +───────┼──────────────────────────────────────────────────────────────────────── + 1 │ struct Rectangle { + 2 │ width: u32, + 3 │ height: u32, + 4 │ } + 5 │ + 6 _ │ fn main() { + 7 │ let rect1 = Rectangle { width: 30, height: 50 }; + 8 │ + 9 │ println!( + 10 ~ │ "The perimeter of the rectangle is {} pixels.", + 11 ~ │ perimeter(&rect1) + 12 │ ); + 13 + │ println!(r#"This line contains invalid utf8: "�����"#; + 14 │ } + 15 │ + 16 │ fn area(rectangle: &Rectangle) -> u32 { + 17 │ rectangle.width * rectangle.height + 18 │ } + 19 + │ + 20 + │ fn perimeter(rectangle: &Rectangle) -> u32 { + 21 + │ (rectangle.width + rectangle.height) * 2 + 22 + │ } +───────┴──────────────────────────────────────────────────────────────────────── diff --git a/tests/snapshots/output/changes_grid_header_rule.snapshot.txt b/tests/snapshots/output/changes_grid_header_rule.snapshot.txt new file mode 100644 index 00000000..655b6e24 --- /dev/null +++ b/tests/snapshots/output/changes_grid_header_rule.snapshot.txt @@ -0,0 +1,26 @@ +──┬───────────────────────────────────────────────────────────────────────────── + │ File: sample.rs +──┼───────────────────────────────────────────────────────────────────────────── + │ struct Rectangle { + │ width: u32, + │ height: u32, + │ } + │ +_ │ fn main() { + │ let rect1 = Rectangle { width: 30, height: 50 }; + │ + │ println!( +~ │ "The perimeter of the rectangle is {} pixels.", +~ │ perimeter(&rect1) + │ ); ++ │ println!(r#"This line contains invalid utf8: "�����"#; + │ } + │ + │ fn area(rectangle: &Rectangle) -> u32 { + │ rectangle.width * rectangle.height + │ } ++ │ ++ │ fn perimeter(rectangle: &Rectangle) -> u32 { ++ │ (rectangle.width + rectangle.height) * 2 ++ │ } +──┴───────────────────────────────────────────────────────────────────────────── diff --git a/tests/snapshots/output/changes_grid_numbers_rule.snapshot.txt b/tests/snapshots/output/changes_grid_numbers_rule.snapshot.txt new file mode 100644 index 00000000..7fe7cccf --- /dev/null +++ b/tests/snapshots/output/changes_grid_numbers_rule.snapshot.txt @@ -0,0 +1,24 @@ +───────┬──────────────────────────────────────────────────────────────────────── + 1 │ struct Rectangle { + 2 │ width: u32, + 3 │ height: u32, + 4 │ } + 5 │ + 6 _ │ fn main() { + 7 │ let rect1 = Rectangle { width: 30, height: 50 }; + 8 │ + 9 │ println!( + 10 ~ │ "The perimeter of the rectangle is {} pixels.", + 11 ~ │ perimeter(&rect1) + 12 │ ); + 13 + │ println!(r#"This line contains invalid utf8: "�����"#; + 14 │ } + 15 │ + 16 │ fn area(rectangle: &Rectangle) -> u32 { + 17 │ rectangle.width * rectangle.height + 18 │ } + 19 + │ + 20 + │ fn perimeter(rectangle: &Rectangle) -> u32 { + 21 + │ (rectangle.width + rectangle.height) * 2 + 22 + │ } +───────┴──────────────────────────────────────────────────────────────────────── diff --git a/tests/snapshots/output/changes_grid_rule.snapshot.txt b/tests/snapshots/output/changes_grid_rule.snapshot.txt new file mode 100644 index 00000000..04767b8b --- /dev/null +++ b/tests/snapshots/output/changes_grid_rule.snapshot.txt @@ -0,0 +1,24 @@ +──┬───────────────────────────────────────────────────────────────────────────── + │ struct Rectangle { + │ width: u32, + │ height: u32, + │ } + │ +_ │ fn main() { + │ let rect1 = Rectangle { width: 30, height: 50 }; + │ + │ println!( +~ │ "The perimeter of the rectangle is {} pixels.", +~ │ perimeter(&rect1) + │ ); ++ │ println!(r#"This line contains invalid utf8: "�����"#; + │ } + │ + │ fn area(rectangle: &Rectangle) -> u32 { + │ rectangle.width * rectangle.height + │ } ++ │ ++ │ fn perimeter(rectangle: &Rectangle) -> u32 { ++ │ (rectangle.width + rectangle.height) * 2 ++ │ } +──┴───────────────────────────────────────────────────────────────────────────── diff --git a/tests/snapshots/output/changes_header_numbers_rule.snapshot.txt b/tests/snapshots/output/changes_header_numbers_rule.snapshot.txt new file mode 100644 index 00000000..77145eb9 --- /dev/null +++ b/tests/snapshots/output/changes_header_numbers_rule.snapshot.txt @@ -0,0 +1,23 @@ + File: sample.rs + 1 struct Rectangle { + 2 width: u32, + 3 height: u32, + 4 } + 5 + 6 _ fn main() { + 7 let rect1 = Rectangle { width: 30, height: 50 }; + 8 + 9 println!( + 10 ~ "The perimeter of the rectangle is {} pixels.", + 11 ~ perimeter(&rect1) + 12 ); + 13 + println!(r#"This line contains invalid utf8: "�����"#; + 14 } + 15 + 16 fn area(rectangle: &Rectangle) -> u32 { + 17 rectangle.width * rectangle.height + 18 } + 19 + + 20 + fn perimeter(rectangle: &Rectangle) -> u32 { + 21 + (rectangle.width + rectangle.height) * 2 + 22 + } diff --git a/tests/snapshots/output/changes_header_rule.snapshot.txt b/tests/snapshots/output/changes_header_rule.snapshot.txt new file mode 100644 index 00000000..82fe8c47 --- /dev/null +++ b/tests/snapshots/output/changes_header_rule.snapshot.txt @@ -0,0 +1,23 @@ + File: sample.rs + struct Rectangle { + width: u32, + height: u32, + } + +_ fn main() { + let rect1 = Rectangle { width: 30, height: 50 }; + + println!( +~ "The perimeter of the rectangle is {} pixels.", +~ perimeter(&rect1) + ); ++ println!(r#"This line contains invalid utf8: "�����"#; + } + + fn area(rectangle: &Rectangle) -> u32 { + rectangle.width * rectangle.height + } ++ ++ fn perimeter(rectangle: &Rectangle) -> u32 { ++ (rectangle.width + rectangle.height) * 2 ++ } diff --git a/tests/snapshots/output/changes_numbers_rule.snapshot.txt b/tests/snapshots/output/changes_numbers_rule.snapshot.txt new file mode 100644 index 00000000..bdfe745b --- /dev/null +++ b/tests/snapshots/output/changes_numbers_rule.snapshot.txt @@ -0,0 +1,22 @@ + 1 struct Rectangle { + 2 width: u32, + 3 height: u32, + 4 } + 5 + 6 _ fn main() { + 7 let rect1 = Rectangle { width: 30, height: 50 }; + 8 + 9 println!( + 10 ~ "The perimeter of the rectangle is {} pixels.", + 11 ~ perimeter(&rect1) + 12 ); + 13 + println!(r#"This line contains invalid utf8: "�����"#; + 14 } + 15 + 16 fn area(rectangle: &Rectangle) -> u32 { + 17 rectangle.width * rectangle.height + 18 } + 19 + + 20 + fn perimeter(rectangle: &Rectangle) -> u32 { + 21 + (rectangle.width + rectangle.height) * 2 + 22 + } diff --git a/tests/snapshots/output/changes_rule.snapshot.txt b/tests/snapshots/output/changes_rule.snapshot.txt new file mode 100644 index 00000000..28d87201 --- /dev/null +++ b/tests/snapshots/output/changes_rule.snapshot.txt @@ -0,0 +1,22 @@ + struct Rectangle { + width: u32, + height: u32, + } + +_ fn main() { + let rect1 = Rectangle { width: 30, height: 50 }; + + println!( +~ "The perimeter of the rectangle is {} pixels.", +~ perimeter(&rect1) + ); ++ println!(r#"This line contains invalid utf8: "�����"#; + } + + fn area(rectangle: &Rectangle) -> u32 { + rectangle.width * rectangle.height + } ++ ++ fn perimeter(rectangle: &Rectangle) -> u32 { ++ (rectangle.width + rectangle.height) * 2 ++ } diff --git a/tests/snapshots/output/grid_header_numbers_rule.snapshot.txt b/tests/snapshots/output/grid_header_numbers_rule.snapshot.txt new file mode 100644 index 00000000..e9f1a9cf --- /dev/null +++ b/tests/snapshots/output/grid_header_numbers_rule.snapshot.txt @@ -0,0 +1,26 @@ +─────┬────────────────────────────────────────────────────────────────────────── + │ File: sample.rs +─────┼────────────────────────────────────────────────────────────────────────── + 1 │ struct Rectangle { + 2 │ width: u32, + 3 │ height: u32, + 4 │ } + 5 │ + 6 │ fn main() { + 7 │ let rect1 = Rectangle { width: 30, height: 50 }; + 8 │ + 9 │ println!( + 10 │ "The perimeter of the rectangle is {} pixels.", + 11 │ perimeter(&rect1) + 12 │ ); + 13 │ println!(r#"This line contains invalid utf8: "�����"#; + 14 │ } + 15 │ + 16 │ fn area(rectangle: &Rectangle) -> u32 { + 17 │ rectangle.width * rectangle.height + 18 │ } + 19 │ + 20 │ fn perimeter(rectangle: &Rectangle) -> u32 { + 21 │ (rectangle.width + rectangle.height) * 2 + 22 │ } +─────┴────────────────────────────────────────────────────────────────────────── diff --git a/tests/snapshots/output/grid_header_rule.snapshot.txt b/tests/snapshots/output/grid_header_rule.snapshot.txt new file mode 100644 index 00000000..50c16941 --- /dev/null +++ b/tests/snapshots/output/grid_header_rule.snapshot.txt @@ -0,0 +1,26 @@ +──────────────────────────────────────────────────────────────────────────────── +File: sample.rs +──────────────────────────────────────────────────────────────────────────────── +struct Rectangle { + width: u32, + height: u32, +} + +fn main() { + let rect1 = Rectangle { width: 30, height: 50 }; + + println!( + "The perimeter of the rectangle is {} pixels.", + perimeter(&rect1) + ); + println!(r#"This line contains invalid utf8: "�����"#; +} + +fn area(rectangle: &Rectangle) -> u32 { + rectangle.width * rectangle.height +} + +fn perimeter(rectangle: &Rectangle) -> u32 { + (rectangle.width + rectangle.height) * 2 +} +──────────────────────────────────────────────────────────────────────────────── diff --git a/tests/snapshots/output/grid_numbers_rule.snapshot.txt b/tests/snapshots/output/grid_numbers_rule.snapshot.txt new file mode 100644 index 00000000..09614667 --- /dev/null +++ b/tests/snapshots/output/grid_numbers_rule.snapshot.txt @@ -0,0 +1,24 @@ +─────┬────────────────────────────────────────────────────────────────────────── + 1 │ struct Rectangle { + 2 │ width: u32, + 3 │ height: u32, + 4 │ } + 5 │ + 6 │ fn main() { + 7 │ let rect1 = Rectangle { width: 30, height: 50 }; + 8 │ + 9 │ println!( + 10 │ "The perimeter of the rectangle is {} pixels.", + 11 │ perimeter(&rect1) + 12 │ ); + 13 │ println!(r#"This line contains invalid utf8: "�����"#; + 14 │ } + 15 │ + 16 │ fn area(rectangle: &Rectangle) -> u32 { + 17 │ rectangle.width * rectangle.height + 18 │ } + 19 │ + 20 │ fn perimeter(rectangle: &Rectangle) -> u32 { + 21 │ (rectangle.width + rectangle.height) * 2 + 22 │ } +─────┴────────────────────────────────────────────────────────────────────────── diff --git a/tests/snapshots/output/grid_rule.snapshot.txt b/tests/snapshots/output/grid_rule.snapshot.txt new file mode 100644 index 00000000..5b970581 --- /dev/null +++ b/tests/snapshots/output/grid_rule.snapshot.txt @@ -0,0 +1,24 @@ +──────────────────────────────────────────────────────────────────────────────── +struct Rectangle { + width: u32, + height: u32, +} + +fn main() { + let rect1 = Rectangle { width: 30, height: 50 }; + + println!( + "The perimeter of the rectangle is {} pixels.", + perimeter(&rect1) + ); + println!(r#"This line contains invalid utf8: "�����"#; +} + +fn area(rectangle: &Rectangle) -> u32 { + rectangle.width * rectangle.height +} + +fn perimeter(rectangle: &Rectangle) -> u32 { + (rectangle.width + rectangle.height) * 2 +} +──────────────────────────────────────────────────────────────────────────────── diff --git a/tests/snapshots/output/header_numbers_rule.snapshot.txt b/tests/snapshots/output/header_numbers_rule.snapshot.txt new file mode 100644 index 00000000..a681e6b4 --- /dev/null +++ b/tests/snapshots/output/header_numbers_rule.snapshot.txt @@ -0,0 +1,23 @@ + File: sample.rs + 1 struct Rectangle { + 2 width: u32, + 3 height: u32, + 4 } + 5 + 6 fn main() { + 7 let rect1 = Rectangle { width: 30, height: 50 }; + 8 + 9 println!( + 10 "The perimeter of the rectangle is {} pixels.", + 11 perimeter(&rect1) + 12 ); + 13 println!(r#"This line contains invalid utf8: "�����"#; + 14 } + 15 + 16 fn area(rectangle: &Rectangle) -> u32 { + 17 rectangle.width * rectangle.height + 18 } + 19 + 20 fn perimeter(rectangle: &Rectangle) -> u32 { + 21 (rectangle.width + rectangle.height) * 2 + 22 } diff --git a/tests/snapshots/output/header_rule.snapshot.txt b/tests/snapshots/output/header_rule.snapshot.txt new file mode 100644 index 00000000..0889edfd --- /dev/null +++ b/tests/snapshots/output/header_rule.snapshot.txt @@ -0,0 +1,23 @@ +File: sample.rs +struct Rectangle { + width: u32, + height: u32, +} + +fn main() { + let rect1 = Rectangle { width: 30, height: 50 }; + + println!( + "The perimeter of the rectangle is {} pixels.", + perimeter(&rect1) + ); + println!(r#"This line contains invalid utf8: "�����"#; +} + +fn area(rectangle: &Rectangle) -> u32 { + rectangle.width * rectangle.height +} + +fn perimeter(rectangle: &Rectangle) -> u32 { + (rectangle.width + rectangle.height) * 2 +} diff --git a/tests/snapshots/output/numbers_rule.snapshot.txt b/tests/snapshots/output/numbers_rule.snapshot.txt new file mode 100644 index 00000000..c1341d29 --- /dev/null +++ b/tests/snapshots/output/numbers_rule.snapshot.txt @@ -0,0 +1,22 @@ + 1 struct Rectangle { + 2 width: u32, + 3 height: u32, + 4 } + 5 + 6 fn main() { + 7 let rect1 = Rectangle { width: 30, height: 50 }; + 8 + 9 println!( + 10 "The perimeter of the rectangle is {} pixels.", + 11 perimeter(&rect1) + 12 ); + 13 println!(r#"This line contains invalid utf8: "�����"#; + 14 } + 15 + 16 fn area(rectangle: &Rectangle) -> u32 { + 17 rectangle.width * rectangle.height + 18 } + 19 + 20 fn perimeter(rectangle: &Rectangle) -> u32 { + 21 (rectangle.width + rectangle.height) * 2 + 22 } diff --git a/tests/snapshots/output/rule.snapshot.txt b/tests/snapshots/output/rule.snapshot.txt new file mode 100644 index 00000000..dbc49f9f --- /dev/null +++ b/tests/snapshots/output/rule.snapshot.txt @@ -0,0 +1,22 @@ +struct Rectangle { + width: u32, + height: u32, +} + +fn main() { + let rect1 = Rectangle { width: 30, height: 50 }; + + println!( + "The perimeter of the rectangle is {} pixels.", + perimeter(&rect1) + ); + println!(r#"This line contains invalid utf8: "�����"#; +} + +fn area(rectangle: &Rectangle) -> u32 { + rectangle.width * rectangle.height +} + +fn perimeter(rectangle: &Rectangle) -> u32 { + (rectangle.width + rectangle.height) * 2 +} diff --git a/tests/syntax-tests/create_highlighted_versions.py b/tests/syntax-tests/create_highlighted_versions.py index c03a0742..4319f47a 100755 --- a/tests/syntax-tests/create_highlighted_versions.py +++ b/tests/syntax-tests/create_highlighted_versions.py @@ -16,11 +16,32 @@ BAT_OPTIONS = [ "--italic-text=always", ] +SKIP_FILENAMES = [ + "LICENSE.md", + "README.md", + "bat_options", +] + + +def get_options(source): + options = BAT_OPTIONS.copy() + + source_dirpath = path.dirname(source) + options_file = path.join(source_dirpath, "bat_options") + try: + with open(options_file, "r") as f: + options.extend(map(lambda x: x.rstrip(), f.readlines())) + except FileNotFoundError: + pass + + return options + def create_highlighted_versions(output_basepath): root = os.path.dirname(os.path.abspath(__file__)) + sources = path.join(root, "source", "*") - for source in glob.glob(path.join(root, "source", "*", "*")): + for source in glob.glob(path.join(sources, "*")) + glob.glob(path.join(sources, ".*")): try: env = os.environ.copy() env.pop("PAGER", None) @@ -31,16 +52,18 @@ def create_highlighted_versions(output_basepath): env.pop("BAT_TABS", None) env["COLORTERM"] = "truecolor" # make sure to output 24bit colors - bat_output = subprocess.check_output( - ["bat"] + BAT_OPTIONS + [source], stderr=subprocess.PIPE, env=env, - ) - source_dirname = path.basename(path.dirname(source)) source_filename = path.basename(source) - if source_filename == "LICENSE.md": + if source_filename in SKIP_FILENAMES: continue + bat_output = subprocess.check_output( + ["bat"] + get_options(source) + [source], + stderr=subprocess.PIPE, + env=env, + ) + output_dir = path.join(output_basepath, source_dirname) output_path = path.join(output_dir, source_filename) @@ -65,7 +88,10 @@ def create_highlighted_versions(output_basepath): ) sys.exit(1) except FileNotFoundError: - print("Error: Could not execute 'bat'. Please make sure that the executable is available on the PATH.") + print( + "Error: Could not execute 'bat'. Please make sure that the executable " + "is available on the PATH." + ) sys.exit(1) diff --git a/tests/syntax-tests/highlighted/ASP/test.asp b/tests/syntax-tests/highlighted/ASP/test.asp new file mode 100644 index 00000000..db610895 --- /dev/null +++ b/tests/syntax-tests/highlighted/ASP/test.asp @@ -0,0 +1,36 @@ +<html> +<body> + + +<% +For i = 0 To 5 +Response.Write("The number is " & i & "
") +Next +%> + +<% +Response.Write("Hello World!") +%> + +<% +Dim x(2,2) +x(0,0)="Volvo" +x(0,1)="BMW" +x(0,2)="Ford" +x(1,0)="Apple" +x(1,1)="Orange" +x(1,2)="Banana" +x(2,0)="Coke" +x(2,1)="Pepsi" +x(2,2)="Sprite" +for i=0 to 2 +response.write("

") +for j=0 to 2 +response.write(x(i,j) & "
") +next +response.write("

") +next +%> + + + diff --git a/tests/syntax-tests/highlighted/ActionScript/test.as b/tests/syntax-tests/highlighted/ActionScript/test.as new file mode 100644 index 00000000..2078c571 --- /dev/null +++ b/tests/syntax-tests/highlighted/ActionScript/test.as @@ -0,0 +1,75 @@ +import flash.events.*; +import flash.events.MouseEvent; + +package TestSyntax { + public class TestSyntax extends flash.display.Sprite { + + public static const TEST_CONSTANT:Number = 33.333; + + var testAttribute:int = 1; + + public namespace TestNamespace; + TestNamespace function Method2():void { } + + /** + * Multi-line comment + */ + override public function set x(value:Number):void + { + super.x = Math.round(value); + } + + /** + * Actual multi-line comment + * Takes up multiple lines + */ + override public function set y(value:Number):void + { + super.y = 0; + } + + public function testFunction() { + var test:String = 'hello'; + + // arrays + var testArray:Array = ["a", "b", "c", "d"]; + for (var i:uint = 0; i < testArray.length; i++) + trace(testArray[i]); + + // objects + var testObject:Object = {foo: 20, bar: 40}; + for (var key:String in testObject) { + trace(testObject[key]); + } + for each (var objectValue:int in testObject) { + trace(objectValue); + } + + // dynamic variables + var testDynamic:*; + testDynamic = 75; + testDynamic = "Seventy-five"; + + // regex + var testRegExp:RegExp = /foo-\d+/i; + + // XML + var testXML:XML = + + Harold</firstName> + Webster</lastName> +</employee>; + } + + private function anotherFunc(a:int, arg2:uint, arg3:Function, ... args) { + + } + + [Embed(source="sound1.mp3")] public var soundCls:Class; + public function SoundAssetExample() + { + var mySound:SoundAsset = new soundCls() as SoundAsset; + var sndChannel:SoundChannel = mySound.play(); + } + } +} diff --git a/tests/syntax-tests/highlighted/Apache/httpd.conf b/tests/syntax-tests/highlighted/Apache/httpd.conf new file mode 100644 index 00000000..80eb01ff --- /dev/null +++ b/tests/syntax-tests/highlighted/Apache/httpd.conf @@ -0,0 +1,42 @@ +# This is a comment +# +ServerRoot "" +Listen 80 +LoadModule mpm_event_module /usr/lib/apache2/modules/mod_mpm_event.so +<IfModule unixd_module> +User daemon +Group daemon + +ServerAdmin you@example.com +<Directory /> + AllowOverride none + Require all denied + +DocumentRoot "/usr/share/apache2/default-site/htdocs" +<Directory "/usr/share/apache2/default-site/htdocs"> + Options Indexes FollowSymLinks + AllowOverride None + Require all granted + +<Files ".ht*"> + Require all denied + +ErrorLog "/var/log/apache2/error_log" +LogLevel warn +<IfModule log_config_module> + LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined + CustomLog "/var/log/apache2/access_log" common + + +<IfModule alias_module> + ScriptAlias /cgi-bin/ "/usr/lib/cgi-bin/" + + +<IfModule mime_module> + TypesConfig /etc/apache2/mime.types + AddType application/x-compress .Z + AddOutputFilter INCLUDES .shtml + +<IfModule proxy_html_module> +Include /etc/apache2/extra/proxy-html.conf + diff --git a/tests/syntax-tests/highlighted/AppleScript/test.applescript b/tests/syntax-tests/highlighted/AppleScript/test.applescript new file mode 100644 index 00000000..f3692a84 --- /dev/null +++ b/tests/syntax-tests/highlighted/AppleScript/test.applescript @@ -0,0 +1,25 @@ +-- This is a comment + +property defaultClientName : "Mary Smith" + +on greetClient(nameOfClient) + display dialog ("Hello " & nameOfClient & "!") +end greetClient + + +script testGreet + greetClient(defaultClientName) +end script + +run testGreet +greetClient("Joe Jones") + +set myList to {1, "what", 3} +set beginning of myList to 0 +set end of myList to "four" + +myList + +tell application "TextEdit" + paragraph 1 of document 1 +end tell diff --git a/tests/syntax-tests/highlighted/Assembly (x86_64)/test.nasm b/tests/syntax-tests/highlighted/Assembly (x86_64)/test.nasm new file mode 100644 index 00000000..816ec75e --- /dev/null +++ b/tests/syntax-tests/highlighted/Assembly (x86_64)/test.nasm @@ -0,0 +1,86 @@ +global enlight + +section .data + red dq 0 ; some comment + green dq 0 + blue dq 0 + data dq 0 + N dd 0 + M dd 0 + change dd 0 + delta db 0 + +section .text +enlight: + call assign_arguments + call set_data + call make_deltas + ret + +assign_arguments: + mov qword[red], rdi + mov qword[green], rsi + mov qword[blue], rdx + mov dword[N], ecx + mov dword[M], r8d + mov dword[change], r9d + mov al, byte[rsp + 16] + mov byte[delta], al + ret + +set_data: + mov eax, dword[change] + cmp eax, 1 + jne not_1 + mov rax, qword[red] + mov qword[data], rax + ret +not_1: + cmp eax, 2 + jne not_2 + mov rax, qword[green] + mov qword[data], rax + ret +not_2: + mov rax, qword[blue] + mov qword[data], rax + ret + + +make_deltas: + mov ecx, dword[N] + mov eax, dword[M] + imul ecx, eax +loop_start: + call make_delta + loop loop_start + ret + +make_delta: + mov rax, qword[data] + add rax, rcx + dec rax + mov dl, byte[delta] + cmp dl, 0 + jl substracting +adding: + add dl, byte[rax] + jc adding_overflow + mov byte[rax], dl + ret +adding_overflow: + mov byte[rax], 255  + ret +substracting: + mov r9b, dl + mov dl, 0 + sub dl, r9b + mov r8b, byte[rax] + sub r8b, dl + jc substracting_overflow + mov byte[rax], r8b + ret +; another comment +substracting_overflow: + mov byte[rax], 0 + ret diff --git a/tests/syntax-tests/highlighted/Batch/build.bat b/tests/syntax-tests/highlighted/Batch/build.bat new file mode 100644 index 00000000..a066dcc8 --- /dev/null +++ b/tests/syntax-tests/highlighted/Batch/build.bat @@ -0,0 +1,59 @@ +@echo off + + +:: Change to your LLVM installation +set "LLVMPath=C:\Program Files\LLVM" +:: Change to your Visual Studio 2017 installation +set "VSPath=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community" +set "VSVersion=14.10.25017" +:: Change to your Windows Kit version & installation +set "WinSDKVersion=10.0.15063.0" +set "WinSDKPath=C:\Program Files (x86)\Windows Kits\10" +:: Change this to your resulting exe +set "OUTPUT=test.exe" + + +:: Setup +set "VSBasePath=%VSPath%\VC\Tools\MSVC\%VSVersion%" +set "PATH=%PATH%;%LLVMPath%\bin;%VSBasePath%\bin\HostX64\x64" + +:: Compiler Flags +set CFLAGS= ^ + -std=c++14 -Wall -Wextra + +set CPPFLAGS= ^ + -I "%VSBasePath%\include" ^ + -I "%WinSDKPath%\Include\%WinSDKVersion%\shared" ^ + -I "%WinSDKPath%\Include\%WinSDKVersion%\ucrt" ^ + -I "%WinSDKPath%\Include\%WinSDKVersion%\um" + + +:: Linker Libs +set LDFLAGS= ^ + -machine:x64 ^ + -nodefaultlib ^ + -subsystem:console + +set LDLIBS= ^ + -libpath:"%VSBasePath%\lib\x64" ^ + -libpath:"%WinSDKPath%\Lib\%WinSDKVersion%\ucrt\x64" ^ + -libpath:"%WinSDKPath%\Lib\%WinSDKVersion%\um\x64" ^ + libucrt.lib libvcruntime.lib libcmt.lib libcpmt.lib ^ + legacy_stdio_definitions.lib oldnames.lib ^ + legacy_stdio_wide_specifiers.lib ^ + kernel32.lib User32.lib + + +:: Compiling +@echo on +@for %%f in (*.cc) do ( + clang++.exe "%%~f" -o "%%~nf.o" -c %CFLAGS% +) + +:: Linking +@set "LINK_FILES=" +@for %%f in (*.o) do ( + @set "LINK_FILES=%LINK_FILES% %%~f" +) + +lld-link.exe %LINK_FILES% -out:"%OUTPUT%" %LDFLAGS% %LDLIBS% diff --git a/tests/syntax-tests/highlighted/BibTeX/test.bib b/tests/syntax-tests/highlighted/BibTeX/test.bib new file mode 100644 index 00000000..4756f514 --- /dev/null +++ b/tests/syntax-tests/highlighted/BibTeX/test.bib @@ -0,0 +1,18 @@ +@book{knuth1997art, + title={The art of computer programming}, + author={Knuth, Donald Ervin}, + volume={3}, + year={1997}, + publisher={Pearson Education} +} + +@article{egholm1993pna, + title={PNA hybridizes to complementary oligonucleotides obeying the Watson--Crick hydrogen-bonding rules}, + author={Egholm, Michael and Buchardt, Ole and Christensen, Leif and Behrens, Carsten and Freier, Susan M and Driver, David A and Berg, Rolf H and Kim, Seog K and Norden, Bengt and Nielsen, Peter E}, + journal={Nature}, + volume={365}, + number={6446}, + pages={566--568}, + year={1993}, + publisher={Springer} +} diff --git a/tests/syntax-tests/highlighted/CMake/CMakeLists.txt b/tests/syntax-tests/highlighted/CMake/CMakeLists.txt new file mode 100644 index 00000000..e4f9e4cc --- /dev/null +++ b/tests/syntax-tests/highlighted/CMake/CMakeLists.txt @@ -0,0 +1,16 @@ +# This is a file for testing syntax highlighting. +cmake_minimum_required(VERSION 3.13) +project(hello-bat VERSION 0.0.1 LANGUAGES C) + +set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/") +file(GLOB_RECURSE SOURCES "${SOURCE_DIR}/*.c") + +add_executable(hello-bat SOURCES) + +find_package(assimp CONFIG) +target_link_libraries(hello-bat assimp) + +option("ENABLE_TESTS" OFF) +if(ENABLE_TESTS) + add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/tests/") +endif() diff --git a/tests/syntax-tests/highlighted/CSS/style.css b/tests/syntax-tests/highlighted/CSS/style.css new file mode 100644 index 00000000..bad4a4dd --- /dev/null +++ b/tests/syntax-tests/highlighted/CSS/style.css @@ -0,0 +1,115 @@ +/*Scrolling*/ +html { scroll-behavior: smooth; } + +/*Header text*/ +.jumbotron { + background-image: linear-gradient(90deg, #849EB5, #30394A); + padding-bottom: 20px; + padding-top: 20px; + text-shadow: 0px 2px 4px #000000; +} + +.container { + margin-top: -25px; +} + +/*Background related*/ +body { + background: #161616; +} + +/*Text related CSS*/ +h4 { + font-size: 70px; + color: #FFFFFF; + font-family: News Cycle, serif; +} + +h3 { + color: #e5e5e5; +} + +p { + font-size: 17px; + font-family: News Cycle, serif; + color: #DEDEDE; +} + +p2 { + font-size: 24px; + color: #DEDEDE; + font-family: News Cycle, serif; +} + +date { + font-family: News Cycle, serif; + font-style: italic; + font-size: 17px; + color: #DEDEDE; +} + +jobtitle { + font-size: 17px; + font-weight: bold; + font-family: News Cycle, serif; + color: #DEDEDE; +} + +jobtilenolink { + font-size: 17px; + font-weight: bold; + font-family: News Cycle, serif; + color: #DEDEDE; +} + +li { + font-family: News Cycle, serif; + color: #DEDEDE; +} + + + +a { + color: #4A8ECC; +} + +p a:visited { + color: #4A8ECC; +} + +.href { + color: #4A8ECC; +} + +a:visited { + color: #4A8ECC; +} + +p a:hover { + color: #4FB1F4; +} + +a:hover { + color: #4FB1F4; +} + +jobtitle:hover { + color: #4FB1F4; +} + +/*Section*/ +section { + background-color: #1B1B1B; + padding: 20px; + margin: -5px; + margin-bottom: 30px; + box-shadow: 0px 2px 4px rgba(0,0,0,0.3); +} + + +/*Icon related*/ +.icon { + position: relative; + top: 3px; + right: 5px; +} diff --git a/tests/syntax-tests/highlighted/CSV/comma_in_quotes.csv b/tests/syntax-tests/highlighted/CSV/comma_in_quotes.csv new file mode 100644 index 00000000..2ad5b914 --- /dev/null +++ b/tests/syntax-tests/highlighted/CSV/comma_in_quotes.csv @@ -0,0 +1,7 @@ +first,last,address,city,zip +John,Doe,120 any st.,"Anytown, WW",08123 +a,b +1,"ha  +""ha""  +ha",120 any st.,"Anytown, WW",08123 +3,4,120 any st.,"Anytown, WW",08123 diff --git a/tests/syntax-tests/highlighted/Clojure/test.clj b/tests/syntax-tests/highlighted/Clojure/test.clj new file mode 100644 index 00000000..32903fe7 --- /dev/null +++ b/tests/syntax-tests/highlighted/Clojure/test.clj @@ -0,0 +1,58 @@ +(ns clojure-sample.core + (:gen-class)) +  + (require '[clj-time.core :as t]) + (require '[clj-time.format :as f]) +  + ;; Product record + (defrecord Product [id name available price]) +  + ;; Positional constructor + (def product1 (->Product "1" "T-Shirt 1" true 15.00)) +  + ;; Map constructor + (def product2 (map->Product + {:id "2" + :name "T-Shirt 2" + :available true + :price 20.00})) +  + ;; Nested + (def product3 {:id "1" + :name "Product 1" + :available true + :sellers [{:id "1" + :name "Seller 1" + :stock 3}, + {:id 2 + :name "Seller 2" + :stock 5}]}) +  + ;; Set + (def categories #{"shirts" "shoes" "belts"}) +  + ;; List + (def wishlist '(1 2)) +  + ;; Recursion + (defn factorial [value] (cond + (<= value 1) 1 + :else (* value (factorial (- value 1))))) +  + (def basic-formatter (f/formatter "YYYY-MM-dd hh:mm:ss")) + (defn now [] (f/unparse basic-formatter (t/now))) + (defn log + ([] (println (now) "No message")) + ([message] (println (now) message))) +  + (defn -main + [& args] + (println (:id product1)) + (println (:name product2)) + (println (:name (get (:sellers product3) 0))) + (println (first categories)) + (println wishlist) + (println (factorial 5)) + (log) + (log "Message")) +  diff --git a/tests/syntax-tests/highlighted/CpuInfo/test.CpuInfo b/tests/syntax-tests/highlighted/CpuInfo/test.CpuInfo new file mode 100644 index 00000000..993fa002 --- /dev/null +++ b/tests/syntax-tests/highlighted/CpuInfo/test.CpuInfo @@ -0,0 +1,45 @@ +processor : 0 +model name : ARMv7 Processor rev 3 (v7l) +BogoMIPS : 270.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xd08 +CPU revision : 3 + +processor : 1 +model name : ARMv7 Processor rev 3 (v7l) +BogoMIPS : 270.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xd08 +CPU revision : 3 + +processor : 2 +model name : ARMv7 Processor rev 3 (v7l) +BogoMIPS : 270.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xd08 +CPU revision : 3 + +processor : 3 +model name : ARMv7 Processor rev 3 (v7l) +BogoMIPS : 270.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xd08 +CPU revision : 3 + +Hardware : BCM2711 +Revision : b03111 +Serial : 1000000095fd9fc5 +Model : Raspberry Pi 4 Model B Rev 1.1 + diff --git a/tests/syntax-tests/highlighted/Crystal/test.cr b/tests/syntax-tests/highlighted/Crystal/test.cr new file mode 100644 index 00000000..d0971438 --- /dev/null +++ b/tests/syntax-tests/highlighted/Crystal/test.cr @@ -0,0 +1,117 @@ +# An example file to test Crystal syntax highlighting in bat +my_var : Nil = nil +my_var_also : Int32 = 42 +my_other_var = 4.0 +another_float = 4.0_f32 +another_float_2 = 4e10 +another_float_3 = -0.5 +big_one = 1_000_000.111_111e-4 +ternary = 1 > 2 : 3 ? 4 +my_symbol = :ThisOne? +my_other_symbol = :No_That_One! +plus = :+ +minus = :- +my_string : String = "this string right here, with an interpolated value of #{my_var_also}" +my_array : Array(Int32) = [1,2,3,4] +my_tuple : Tuple(Int32, Int32, Int32, Int32) = {1,2,3,4} +my_named_tuple : NamedTuple(one: Int32, two: Int32) = {"one": 1, "two": 2} +my_hash : Hash(String, Int32) = {"one" => 1, "two" => 2} +my_proc : Proc(Int32, Int32) = ->(x : Int32){ x * x} +my_other_proc : Proc(String) = ->{ "Wow, neat!" } +puts my_string +puts(my_string) + +enum Colors + Red + Green + Blue +end + +class Greeter + @instance_field = Colors::Red + @@class_field = Colors::Green + + def initialize(@name = "world") + end + + def greet  + puts "Hello, #{@name}" + end + + def render_greeting : String + "Hello, #{@name}" + end + + def with_greeting + yield render_greeting + end + + def is_color_default? + @instance_field == @@class_field + end + + def self.greet_static(name : String) : Unit + puts "Hello, #{name}" + end +end + +greeter = Greeter.new("bat") +greeter.with_greeting do |greeting| + puts greeting +end + +puts <<-EOF + this is a heredoc and it has a value in it of #{greeter.render_greeting}! +EOF + +# This is a command: +`echo yay!` +$?.success? + +my_color = Colors::Red + +puts  + case my_color + when Colors::Red, .red? + "Red" + when Colors::Green, .green? + "Green" + when Colors::Blue, .blue? + "Blue" + else + "I dunno, man. Chartreuse? Maroon?" + end + +class MyGenericClass(T) + def initialize(@wrapped_value : T) + end + + def get + return @wrapped_value + end +end + + +def do_stuff_with_range(r : Range(Int|String)) + return if r.empty? + return unless !(r.empty?) + r.each do |item| + if /e/.match(item.to_s) + puts "#{item} contains the letter e!" + elsif item.to_s.empty? + break + else + next # this is unnecessary, but whatever + end + end +end + + +macro print_range(range) + {% for i in range %} + puts {{i.id}} + {% end %} +end + +print_range(1..3) +print_range(1...3) diff --git a/tests/syntax-tests/highlighted/D/test.d b/tests/syntax-tests/highlighted/D/test.d new file mode 100644 index 00000000..da347147 --- /dev/null +++ b/tests/syntax-tests/highlighted/D/test.d @@ -0,0 +1,44 @@ +// selective import +import std.stdio : writeln, writefln; +// non-selective import +import std.algorithm; + +/* a multiline comment +* +* this function is safe because it doesn't use pointer arithmetic +*/ +int the_ultimate_answer() @safe { + // assert1on + assert(1 != 2); + // now we can safely return our answer  + return 42; +} + +void main() +{ + // function call with string literal + writeln("Hello World!"); + + // an int array declaration + int[] arr1 = [1, 2, 3]; + // an immutable double + immutable double pi = 3.14; + // a mutable double + double d1 = pi; + // a pointer + double* dp1 = &d1; + // another pointer to the same thingy + auto a1 = &d1; + // a constant bool + const bool b1 = true; + if (b1) { + // another function call  + writefln("%s\n%s\n%s\n", arr1, d1, the_ultimate_answer()); + } + else if (!b1) { + writeln("this seems wrong"); + } + else { + writeln("I'm giving up, this is too crazy for me"); + } +} diff --git a/tests/syntax-tests/highlighted/Diff/82e7786e747b1fcfac1f963ae6415a22ec9caae1.diff b/tests/syntax-tests/highlighted/Diff/82e7786e747b1fcfac1f963ae6415a22ec9caae1.diff new file mode 100644 index 00000000..39f95b74 --- /dev/null +++ b/tests/syntax-tests/highlighted/Diff/82e7786e747b1fcfac1f963ae6415a22ec9caae1.diff @@ -0,0 +1,353 @@ +diff --git a/CHANGELOG.md b/CHANGELOG.md +index ced88213..973eba9a 100644 +--- a/CHANGELOG.md ++++ b/CHANGELOG.md +@@ -2,6 +2,11 @@ +  +  + ## Features ++ ++- Add a new `--diff` option that can be used to only show lines surrounding ++ Git changes, i.e. added, removed or modified lines. The amount of additional ++ context can be controlled with `--diff-context=N`. See #23 and #940 ++ + ## Bugfixes + ## Other + ## `bat` as a library +diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs +index e5221455..f0f519ea 100644 +--- a/src/bin/bat/app.rs ++++ b/src/bin/bat/app.rs +@@ -15,7 +15,7 @@ use console::Term; +  + use bat::{ + assets::HighlightingAssets, +- config::Config, ++ config::{Config, VisibleLines}, + error::*, + input::Input, + line_range::{HighlightedLineRanges, LineRange, LineRanges}, +@@ -196,13 +196,23 @@ impl App { + } + }) + .unwrap_or_else(|| String::from(HighlightingAssets::default_theme())), +- line_ranges: self +- .matches +- .values_of("line-range") +- .map(|vs| vs.map(LineRange::from).collect()) +- .transpose()? +- .map(LineRanges::from) +- .unwrap_or_default(), ++ visible_lines: if self.matches.is_present("diff") { ++ VisibleLines::DiffContext( ++ self.matches ++ .value_of("diff-context") ++ .and_then(|t| t.parse().ok()) ++ .unwrap_or(2), ++ ) ++ } else { ++ VisibleLines::Ranges( ++ self.matches ++ .values_of("line-range") ++ .map(|vs| vs.map(LineRange::from).collect()) ++ .transpose()? ++ .map(LineRanges::from) ++ .unwrap_or_default(), ++ ) ++ }, + style_components, + syntax_mapping, + pager: self.matches.value_of("pager"), +diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs +index c7344991..85edefde 100644 +--- a/src/bin/bat/clap_app.rs ++++ b/src/bin/bat/clap_app.rs +@@ -105,6 +105,34 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { + data to bat from STDIN when bat does not otherwise know \ + the filename."), + ) ++ .arg( ++ Arg::with_name("diff") ++ .long("diff") ++ .help("Only show lines that have been added/removed/modified.") ++ .long_help( ++ "Only show lines that have been added/removed/modified with respect \ ++ to the Git index. Use --diff-context=N to control how much context you want to see.", ++ ), ++ ) ++ .arg( ++ Arg::with_name("diff-context") ++ .long("diff-context") ++ .overrides_with("diff-context") ++ .takes_value(true) ++ .value_name("N") ++ .validator( ++ |n| { ++ n.parse::() ++ .map_err(|_| "must be a number") ++ .map(|_| ()) // Convert to Result<(), &str> ++ .map_err(|e| e.to_string()) ++ }, // Convert to Result<(), String> ++ ) ++ .hidden_short_help(true) ++ .long_help( ++ "Include N lines of context around added/removed/modified lines when using '--diff'.", ++ ), ++ ) + .arg( + Arg::with_name("tabs") + .long("tabs") +@@ -339,6 +367,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { + .takes_value(true) + .number_of_values(1) + .value_name("N:M") ++ .conflicts_with("diff") + .help("Only print the lines from N to M.") + .long_help( + "Only print the specified range of lines for each file. \ +diff --git a/src/config.rs b/src/config.rs +index d5df9910..3c24b77f 100644 +--- a/src/config.rs ++++ b/src/config.rs +@@ -5,6 +5,32 @@ use crate::style::StyleComponents; + use crate::syntax_mapping::SyntaxMapping; + use crate::wrapping::WrappingMode; +  ++#[derive(Debug, Clone)] ++pub enum VisibleLines { ++ /// Show all lines which are included in the line ranges ++ Ranges(LineRanges), ++ ++ #[cfg(feature = "git")] ++ /// Only show lines surrounding added/deleted/modified lines ++ DiffContext(usize), ++} ++ ++impl VisibleLines { ++ pub fn diff_context(&self) -> bool { ++ match self { ++ Self::Ranges(_) => false, ++ #[cfg(feature = "git")] ++ Self::DiffContext(_) => true, ++ } ++ } ++} ++ ++impl Default for VisibleLines { ++ fn default() -> Self { ++ VisibleLines::Ranges(LineRanges::default()) ++ } ++} ++ + #[derive(Debug, Clone, Default)] + pub struct Config<'a> { + /// The explicitly configured language, if any +@@ -39,8 +65,8 @@ pub struct Config<'a> { + #[cfg(feature = "paging")] + pub paging_mode: PagingMode, +  +- /// Specifies the lines that should be printed +- pub line_ranges: LineRanges, ++ /// Specifies which lines should be printed ++ pub visible_lines: VisibleLines, +  + /// The syntax highlighting theme + pub theme: String, +@@ -62,10 +88,7 @@ pub struct Config<'a> { + fn default_config_should_include_all_lines() { + use crate::line_range::RangeCheckResult; +  +- assert_eq!( +- Config::default().line_ranges.check(17), +- RangeCheckResult::InRange +- ); ++ assert_eq!(LineRanges::default().check(17), RangeCheckResult::InRange); + } +  + #[test] +diff --git a/src/controller.rs b/src/controller.rs +index 09c6ec2a..f636d5fd 100644 +--- a/src/controller.rs ++++ b/src/controller.rs +@@ -1,9 +1,13 @@ + use std::io::{self, Write}; +  + use crate::assets::HighlightingAssets; +-use crate::config::Config; ++use crate::config::{Config, VisibleLines}; ++#[cfg(feature = "git")] ++use crate::diff::{get_git_diff, LineChanges}; + use crate::error::*; + use crate::input::{Input, InputReader, OpenedInput}; ++#[cfg(feature = "git")] ++use crate::line_range::LineRange; + use crate::line_range::{LineRanges, RangeCheckResult}; + use crate::output::OutputType; + #[cfg(feature = "paging")] +@@ -68,6 +72,32 @@ impl<'b> Controller<'b> { + no_errors = false; + } + Ok(mut opened_input) => { ++ #[cfg(feature = "git")] ++ let line_changes = if self.config.visible_lines.diff_context() ++ || (!self.config.loop_through && self.config.style_components.changes()) ++ { ++ if let crate::input::OpenedInputKind::OrdinaryFile(ref path) = ++ opened_input.kind ++ { ++ let diff = get_git_diff(path); ++ ++ if self.config.visible_lines.diff_context() ++ && diff ++ .as_ref() ++ .map(|changes| changes.is_empty()) ++ .unwrap_or(false) ++ { ++ continue; ++ } ++ ++ diff ++ } else { ++ None ++ } ++ } else { ++ None ++ }; ++ + let mut printer: Box = if self.config.loop_through { + Box::new(SimplePrinter::new()) + } else { +@@ -75,10 +105,18 @@ impl<'b> Controller<'b> { + &self.config, + &self.assets, + &mut opened_input, ++ #[cfg(feature = "git")] ++ &line_changes, + )) + }; +  +- let result = self.print_file(&mut *printer, writer, &mut opened_input); ++ let result = self.print_file( ++ &mut *printer, ++ writer, ++ &mut opened_input, ++ #[cfg(feature = "git")] ++ &line_changes, ++ ); +  + if let Err(error) = result { + handle_error(&error); +@@ -96,13 +134,31 @@ impl<'b> Controller<'b> { + printer: &mut dyn Printer, + writer: &mut dyn Write, + input: &mut OpenedInput, ++ #[cfg(feature = "git")] line_changes: &Option, + ) -> Result<()> { + if !input.reader.first_line.is_empty() || self.config.style_components.header() { + printer.print_header(writer, input)?; + } +  + if !input.reader.first_line.is_empty() { +- self.print_file_ranges(printer, writer, &mut input.reader, &self.config.line_ranges)?; ++ let line_ranges = match self.config.visible_lines { ++ VisibleLines::Ranges(ref line_ranges) => line_ranges.clone(), ++ #[cfg(feature = "git")] ++ VisibleLines::DiffContext(context) => { ++ let mut line_ranges: Vec = vec![]; ++ ++ if let Some(line_changes) = line_changes { ++ for line in line_changes.keys() { ++ let line = *line as usize; ++ line_ranges.push(LineRange::new(line - context, line + context)); ++ } ++ } ++ ++ LineRanges::from(line_ranges) ++ } ++ }; ++ ++ self.print_file_ranges(printer, writer, &mut input.reader, &line_ranges)?; + } + printer.print_footer(writer, input)?; +  +diff --git a/src/pretty_printer.rs b/src/pretty_printer.rs +index 0c78ea90..13bd5dbc 100644 +--- a/src/pretty_printer.rs ++++ b/src/pretty_printer.rs +@@ -6,7 +6,7 @@ use syntect::parsing::SyntaxReference; +  + use crate::{ + assets::HighlightingAssets, +- config::Config, ++ config::{Config, VisibleLines}, + controller::Controller, + error::Result, + input::Input, +@@ -205,7 +205,7 @@ impl<'a> PrettyPrinter<'a> { +  + /// Specify the lines that should be printed (default: all) + pub fn line_ranges(&mut self, ranges: LineRanges) -> &mut Self { +- self.config.line_ranges = ranges; ++ self.config.visible_lines = VisibleLines::Ranges(ranges); + self + } +  +diff --git a/src/printer.rs b/src/printer.rs +index 5eed437e..2b245cfd 100644 +--- a/src/printer.rs ++++ b/src/printer.rs +@@ -24,7 +24,7 @@ use crate::config::Config; + use crate::decorations::LineChangesDecoration; + use crate::decorations::{Decoration, GridBorderDecoration, LineNumberDecoration}; + #[cfg(feature = "git")] +-use crate::diff::{get_git_diff, LineChanges}; ++use crate::diff::LineChanges; + use crate::error::*; + use crate::input::OpenedInput; + use crate::line_range::RangeCheckResult; +@@ -90,7 +90,7 @@ pub(crate) struct InteractivePrinter<'a> { + ansi_prefix_sgr: String, + content_type: Option, + #[cfg(feature = "git")] +- pub line_changes: Option, ++ pub line_changes: &'a Option, + highlighter: Option>, + syntax_set: &'a SyntaxSet, + background_color_highlight: Option, +@@ -101,6 +101,7 @@ impl<'a> InteractivePrinter<'a> { + config: &'a Config, + assets: &'a HighlightingAssets, + input: &mut OpenedInput, ++ #[cfg(feature = "git")] line_changes: &'a Option, + ) -> Self { + let theme = assets.get_theme(&config.theme); +  +@@ -145,9 +146,6 @@ impl<'a> InteractivePrinter<'a> { + panel_width = 0; + } +  +- #[cfg(feature = "git")] +- let mut line_changes = None; +- + let highlighter = if input + .reader + .content_type +@@ -155,18 +153,6 @@ impl<'a> InteractivePrinter<'a> { + { + None + } else { +- // Get the Git modifications +- #[cfg(feature = "git")] +- { +- use crate::input::OpenedInputKind; +- +- if config.style_components.changes() { +- if let OpenedInputKind::OrdinaryFile(ref path) = input.kind { +- line_changes = get_git_diff(path); +- } +- } +- } +- + // Determine the type of syntax for highlighting + let syntax = assets.get_syntax(config.language, input, &config.syntax_mapping); + Some(HighlightLines::new(syntax, theme)) diff --git a/tests/syntax-tests/highlighted/Dockerfile/Dockerfile b/tests/syntax-tests/highlighted/Dockerfile/Dockerfile new file mode 100644 index 00000000..fcbe51c1 --- /dev/null +++ b/tests/syntax-tests/highlighted/Dockerfile/Dockerfile @@ -0,0 +1,19 @@ +ARG architecture=amd64 +FROM $architecture/centos:7 +LABEL com.example.version="0.2.1-beta" +ARG architecture + +ENV INTERESTING_PATH /usr/bin/interesting-software + + +COPY entrypoint.sh /usr/bin/entrypoint.sh + +RUN if [ "$architecture" = "i386" ]; then echo "Building i386 docker image" && \ + linux32 yum update -y && linux32 yum install -y mysql ; \ + else yum update -y && yum install -y mysql + +EXPOSE 80/tcp + +VOLUME [/var/lib/mysql/data] + +ENTRYPOINT ["/usr/bin/entrypoint.sh"] diff --git a/tests/syntax-tests/highlighted/DotENV/.env b/tests/syntax-tests/highlighted/DotENV/.env new file mode 100644 index 00000000..f46097cc --- /dev/null +++ b/tests/syntax-tests/highlighted/DotENV/.env @@ -0,0 +1,57 @@ +# Keyword +export TEST_KEYWORD="bar" +export TEST_KEYWORD=12345 +export TEST_KEYWORD=TRUE + +# Variable +TEST_VARIABLE="Hello" + +# String interpolation +TEST_INTERPOLATION_VARIABLE="$VAR1 test test$VAR2test test" +TEST_INTERPOLATION_SYNTAX_ONE="test test{$NVAR1}test{$NVAR2}test test" +TEST_INTERPOLATION_SYNTAX_TWO="test test${NVAR1}test${NVAR2}test test" +TEST_INTERPOLATION_SYNTAX_ALL="test$VAR1test test {VAR2}test test${VAR3}test" + +# Unquoted +TEST_UNQUOTED=bar +TEST_UNQUOTED_NO_VALUE= + +# White spaced +TEST_WHITE_SPACE = +TEST_WHITE_SPACE_STRING = "Hello" +TEST_WHITE_SPACE_UNQUOTED = bar +TEST_WHITE_SPACE_UNQUOTED_BOOL = false +TEST_WHITE_SPACE_UNQUOTED_NUM = 20 + +# language constants +TEST_TRUE=true +TEST_FALSE=false +TEST_NULL=null +TEST_TRUE_CAPITAL=TRUE +TEST_FALSE_CAPITAL=FALSE +TEST_NULL_CAPITAL=NULL + +# Numerical values +TEST_NUM_DECIMAL=54 +TEST_NUM_FLOAT=5.3 +TEST_NUM=1e10 +TEST_NUM_NEGATIVE=-42 +TEST_NUM_OCTAL=057 +TEST_NUM_HEX=0x1A + +# Comments +#TEST_ONE=foobar +# TEST_TWO='foobar' +# TEST_THREE="foobar" # a comment on a commented row +TEST_FOUR="test test test" # this is a comment +TEST_FIVE="comment symbol # inside string" # this is a comment +TEST_SIX="comment symbol # and quotes \" \' inside quotes" # " this is a comment + +# Escape sequences +TEST_ESCAPE="escaped characters \n \t \r \" \' \$ or maybe a backslash \\..." + +# Double Quotes +TEST_DOUBLE="Lorem {$VAR1} ${VAR2} $VAR3 ipsum dolor sit amet\n\r\t\\" + +# Single Quotes +TEST_SINGLE='Lorem {$VAR1} ${VAR2} $VAR3 ipsum dolor sit amet\n\r\t\\' diff --git a/tests/syntax-tests/highlighted/Erlang/bat_erlang.erl b/tests/syntax-tests/highlighted/Erlang/bat_erlang.erl new file mode 100644 index 00000000..ccf7817d --- /dev/null +++ b/tests/syntax-tests/highlighted/Erlang/bat_erlang.erl @@ -0,0 +1,72 @@ +-module(bat_erlang). + +-export([main/0]). + +-record(test, { + name :: list(), + data :: binary() +}). + +-define(TESTMACRO, "testmacro"). + +-spec main() -> ok. +main() -> + %% Handling Lists and Numbers + List = [1, 2, 3, 4, $6, 2#00111], + _Sum = lists:sum(List), + _ = [(N * N) + N / N - N || N <- List, N > 2], + [_Head, _SecondHead | _Tail] = List, + _ = [1, atom, [list], <<"binary">>, {tuple, tuple}, #{map => key}, #test{name = "record"}], + + %% Handling Binaries  + BinHelloWorld = <<"Hello World">>, + <<X || <<X:1/binary>> <= BinHelloWorld >>, + <<0,0,0,0,0,0,0,151>> = <<151:64/signed-integer>>, + + %% Handling Boolean and Atoms + true = true andalso true, + true = false orelse true, + _ = true =:= true, + _ = false =/= true, + _ = 'HELLO' /= hello, + _ = hello == world, + + %% Handling Maps and Records + TestMap = #{a => 1, b => 2, c => 3}, + #{a := _Value, c := _} = TestMap, + _ = TestMap#{d => 4}, + Record = #test{name = ?TESTMACRO}, + _ = Record#test.name, + + %% Conditionals + case TestMap of + #{b := B} -> + B; + _ -> + ok + end, + if + erlang:is_map(TestMap) -> + map; + true -> + test_function(1) + end, + + %% Messaging + Self = erlang:self(), + Self ! hello_world, + receive + hello_world -> + ok; + _ -> + io:format("unknown message") + after 1000 -> + timeout + end, + ok. + +test_function(N) when erlang:is_integer(N) -> integer; +test_function([_|_]) -> list; +test_function(<<_/binary>>) -> binary; +test_function(_) -> + undefined. diff --git a/tests/syntax-tests/highlighted/EtcGroup/test.group b/tests/syntax-tests/highlighted/EtcGroup/test.group new file mode 100644 index 00000000..5049c80e --- /dev/null +++ b/tests/syntax-tests/highlighted/EtcGroup/test.group @@ -0,0 +1,67 @@ +root:x:0:root +sys:x:3:bin +mem:x:8: +ftp:x:11: +mail:x:12: +log:x:19: +smmsp:x:25: +proc:x:26:polkitd +games:x:50: +lock:x:54: +network:x:90: +floppy:x:94: +scanner:x:96: +power:x:98: +adm:x:999:daemon +wheel:x:998:username +kmem:x:997: +tty:x:5: +utmp:x:996: +audio:x:995:mpd,username +disk:x:994: +input:x:993: +kvm:x:992: +lp:x:991: +optical:x:990:username +render:x:989: +storage:x:988:username +uucp:x:987: +video:x:986:username +users:x:985: +systemd-journal:x:984: +rfkill:x:983: +bin:x:1:daemon +daemon:x:2:bin +http:x:33: +nobody:x:65534: +dbus:x:81: +systemd-journal-remote:x:982: +systemd-network:x:981: +systemd-resolve:x:980: +systemd-timesync:x:979: +systemd-coredump:x:978: +uuidd:x:68: +username:x:1000: +git:x:977: +avahi:x:976: +colord:x:975: +polkitd:x:102: +mpd:x:45: +rtkit:x:133: +transmission:x:169: +wireshark:x:150:username +lightdm:x:974: +geoclue:x:973: +usbmux:x:140: +dhcpcd:x:972: +brlapi:x:971: +gdm:x:120: +libvirt:x:970: +flatpak:x:969: +gluster:x:968: +rpc:x:32: +tor:x:43: +rslsync:x:967: +docker:x:966:username +sambashare:x:1002:username +named:x:40: diff --git a/tests/syntax-tests/highlighted/Fish/test.fish b/tests/syntax-tests/highlighted/Fish/test.fish new file mode 100644 index 00000000..3e7d8b86 --- /dev/null +++ b/tests/syntax-tests/highlighted/Fish/test.fish @@ -0,0 +1,77 @@ +set fish_greeting "" + +begin + set --local AUTOJUMP_PATH $XDG_CONFIG_HOME/fish/functions/autojump.fish + if test -e $AUTOJUMP_PATH + source $AUTOJUMP_PATH + end +end + +fish_vi_key_bindings + + +function fish_prompt + set_color brblack + echo -n "["(date "+%H:%M")"] " + set_color blue + echo -n (hostname) + if [ $PWD != $HOME ] + set_color brblack + echo -n ':' + set_color yellow + echo -n (basename $PWD) + end + set_color green + printf '%s ' (__fish_git_prompt) + set_color red + echo -n '| ' + set_color normal +end + +function fish_greeting + echo + echo -e (uname -ro | awk '{print " \\\\e[1mOS: \\\\e[0;32m"$0"\\\\e[0m"}') + echo -e (uptime -p | sed 's/^up //' | awk '{print " \\\\e[1mUptime: \\\\e[0;32m"$0"\\\\e[0m"}') + echo -e (uname -n | awk '{print " \\\\e[1mHostname: \\\\e[0;32m"$0"\\\\e[0m"}') + echo -e " \\e[1mDisk usage:\\e[0m" + echo + echo -ne (\ + df -l -h | grep -E 'dev/(xvda|sd|mapper)' | \ + awk '{printf "\\\\t%s\\\\t%4s / %4s %s\\\\n\n", $6, $3, $2, $5}' | \ + sed -e 's/^\(.*\([8][5-9]\|[9][0-9]\)%.*\)$/\\\\e[0;31m\1\\\\e[0m/' -e 's/^\(.*\([7][5-9]\|[8][0-4]\)%.*\)$/\\\\e[0;33m\1\\\\e[0m/' | \ + paste -sd ''\ + ) + echo + + echo -e " \\e[1mNetwork:\\e[0m" + echo + # http://tdt.rocks/linux_network_interface_naming.html + echo -ne (\ + ip addr show up scope global | \ + grep -E ': <|inet' | \ + sed \ + -e 's/^[[:digit:]]\+: //' \ + -e 's/: <.*//' \ + -e 's/.*inet[[:digit:]]* //' \ + -e 's/\/.*//'| \ + awk 'BEGIN {i=""} /\.|:/ {print i" "$0"\\\n"; next} // {i = $0}' | \ + sort | \ + column -t -R1 | \ + # public addresses are underlined for visibility \ + sed 's/ \([^ ]\+\)$/ \\\e[4m\1/' | \ + # private addresses are not \ + sed 's/m\(\(10\.\|172\.\(1[6-9]\|2[0-9]\|3[01]\)\|192\.168\.\).*\)/m\\\e[24m\1/' | \ + # unknown interfaces are cyan \ + sed 's/^\( *[^ ]\+\)/\\\e[36m\1/' | \ + # ethernet interfaces are normal \ + sed 's/\(\(en\|em\|eth\)[^ ]* .*\)/\\\e[39m\1/' | \ + # wireless interfaces are purple \ + sed 's/\(wl[^ ]* .*\)/\\\e[35m\1/' | \ + # wwan interfaces are yellow \ + sed 's/\(ww[^ ]* .*\).*/\\\e[33m\1/' | \ + sed 's/$/\\\e[0m/' | \ + sed 's/^/\t/' \ + ) + echo + set_color normal +end diff --git a/tests/syntax-tests/highlighted/GLSL/test.glsl b/tests/syntax-tests/highlighted/GLSL/test.glsl new file mode 100644 index 00000000..1233c312 --- /dev/null +++ b/tests/syntax-tests/highlighted/GLSL/test.glsl @@ -0,0 +1,42 @@ +#version 330 core + +#ifdef TEST +layout (location = 0) in vec4 vertex; +#else +layout (location = 6) in vec4 vertex; +#endif + +out vec2 p_textureVertex; + +/* + * This stores offsets + */ +struct Data +{ + double offsetX; + double offsetY; +} + +uniform mat4 projectionMatrix; +uniform bool test; +uniform Data data; + +double calc() +{ + if (test) + { + return 1.0; + } + else + { + return 0.0; + } +} + +void main() +{ + // This GLSL code serves the purpose of bat syntax highlighting tests + double x = data.offsetX + calc(); + gl_Position = projectionMatrix * vec4(vertex.xy, data.offsetX, data.offsetY); + p_textureVertex = vertex.zw; +} diff --git a/tests/syntax-tests/highlighted/Git Attributes/example.gitattributes b/tests/syntax-tests/highlighted/Git Attributes/example.gitattributes new file mode 100644 index 00000000..178bc759 --- /dev/null +++ b/tests/syntax-tests/highlighted/Git Attributes/example.gitattributes @@ -0,0 +1,16 @@ +# +# Comment + +[attr]binary -diff -merge -text + +* text=auto +*.c diff=c +*.cc text diff=cpp +*.o binary +*.bat text eol=crlf +*.lock text -diff +*.*ignore text +*.patch -text + +.gitattributes linguist-language=gitattributes +.gitkeep export-ignore diff --git a/tests/syntax-tests/highlighted/Git Config/text.gitconfig b/tests/syntax-tests/highlighted/Git Config/text.gitconfig new file mode 100644 index 00000000..91f3b08c --- /dev/null +++ b/tests/syntax-tests/highlighted/Git Config/text.gitconfig @@ -0,0 +1,107 @@ +[alias] + br = branch + branch = branch -a + c = clone --recursive + ci = commit + cl = clone + co = checkout + contributors = shortlog --summary --numbered + lg = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' + remote = remote -v + st = status + tag = tag -l +[apply] + whitespace = fix +[color] + ui = true +[color "branch"] + current = yellow + local = yellow + remote = green +[color "diff"] + commit = yellow bold + frag = magenta bold + meta = yellow + new = green bold + old = red bold + whitespace = red reverse +[color "diff-highlight"] + newHighlight = green bold 22 + newNormal = green bold + oldHighlight = red bold 52 + oldNormal = red bold +[color "status"] + added = green + changed = yellow + untracked = cyan +[commit] + gpgsign = true +[core] + editor = /usr/bin/vim + # global exclude + excludesfile = /home/frank/.config/git/ignore + pager = delta + ; broken on old machines + untrackedCache = true +[credential] + helper = store +[delta] + features = line-numbers decorations + max-line-length = 1024 + whitespace-error-style = 22 reverse +[delta "decorations"] + commit-decoration-style = bold yellow box ul + file-decoration-style = none + file-style = bold yellow + syntax-theme = gruvbox +[diff] + submodule = diff + algorithm = histogram + renames = copies +[difftool] + prompt = false +[difftool "wrapper"] + binary = true + cmd = git-difftool-wrapper \"$LOCAL\" \"$REMOTE\" +[diff "pdfconv"] + textconv = pdftohtml -stdout +[fetch] + negotiationAlgorithm = skipping + parallel = 0 +[help] + autocorrect = 1 +[index] + version = 4 +[interactive] + diffFilter = delta --color-only +[merge] + log = true +[protocol] + version = 2 +[pull] + rebase = true +[push] + default = current + recurseSubmodules = on-demand +[rebase] + autoStash = true +[rerere] + autoUpdate = true + enabled = true +[sequence] + editor = interactive-rebase-tool +[submodule] + fetchJobs = 0 +[tag] + gpgSign = true + sort = -version:refname +[url "git@gist.github.com:"] + insteadOf = gist: + pushInsteadOf = https://gist.github.com/ +[url "git@github.com:"] + insteadOf = gh: + pushInsteadOf = https://github.com/ +[user] + email = f.nord@example.com + name = Frank Nord + signingkey = AAAAAAAAAAAAAAAA diff --git a/tests/syntax-tests/highlighted/GraphQL/test.graphql b/tests/syntax-tests/highlighted/GraphQL/test.graphql new file mode 100644 index 00000000..28670a98 --- /dev/null +++ b/tests/syntax-tests/highlighted/GraphQL/test.graphql @@ -0,0 +1,145 @@ +# Token:: +# Punctuator +# Name +# IntValue +# FloatValue +# StringValue + +# Punctuator:: one of +# ! $ ( ) ... : = @ [ ] { | } + +# Name:: +# /[_A-Za-z][_0-9A-Za-z]*/ + +# Document : +# Definition (list) + +# Definition : +# ExecutableDefinition +# TypeSystemDefinition +# TypeSystemExtension + +# ExecutableDefinition : +# FragmentDefinition +# OperationDefintion + +# FragmentDefinition + +type someType { + id: ID +} + +fragment subsriberFields on someType { + id + name + fooInt(int: 1234, negInt: -56789, zero: 0) + fooFloat( + float: 1.1 + floatExp: 1.4e10 + floatExpSign1: 1.4e+10 + floatExpSign2: 1.5e-40 + floatExpBigE: 1.5E10 + ) + fooBool(x: true, y: false) + fooString(str: "hello", strUni: "\u2116", strEscWs: "\t") + fooLongStr( + lStr: """ + Hello Reader, + This is a long string block. + Best, + Writer + """ + ) + fooNull(nullThing: null) + fooList(numList: [1, 2, 3], strList: ["a", "b", "c"]) + fooObj(someObj: { str: "hi", int: 2 }) +} + +# OperationDefintion + +query _A1 { + getThings(strArg: "string") { + id # commas here are ignored but valid + name + } +} + +query _A2($x: String) { + someFn(episode: $x) { + name + } +} + +mutation B1 { + changeThings(intArg: 123) { + parent { + nestedField1 + nestedField2 + } + } +} + +subscription C1_Hello { + subsribePlease(floatArg: 1.4) { + id + ...subsriberFields + } +} + +# TypeSystemDefinition : +# SchemaDefinition +# TypeDefinition + +schema { + query: Query + mutation: Mutation +} + +type Query { + """ + Can provide documentation this way. + """ + scalars: Scalars + someList: SomeLists + fooBar: FooBar +} + +interface Thing { + id: ID! +} + +type Scalars implements Thing { + id: ID! + int: Int! + float: Float! + str: String! @deprecated(reason: "Need to test a directive") + bool: Boolean + type: StringTypes +} + +type SomeLists { + ints: [Int!]! +} + +type Foo { + fooVal: String +} + +type Bar { + barVal: String +} + +union FooBar = Foo | Bar + +enum StringTypes { + ONE + TWO +} + +input Xyz { + id: ID! +} + +type Mutation { + createXyz(input: xyz!): Xyz! +} diff --git a/tests/syntax-tests/highlighted/Graphviz DOT/test_digraph.dot b/tests/syntax-tests/highlighted/Graphviz DOT/test_digraph.dot new file mode 100644 index 00000000..dddc1366 --- /dev/null +++ b/tests/syntax-tests/highlighted/Graphviz DOT/test_digraph.dot @@ -0,0 +1,41 @@ +digraph { + label = <Label <font color='red'><b>formating,<br/> test <font point-size='20'>is done<br/> here <i>now.>; + + node [shape=box] + rankdir=LR + margin=0.1 + a->b + + // http://www.graphviz.org/doc/info/colors.html + // note: style=filled! + node [shape=box colorscheme=paired12 style=filled] + margin=0.1 + a2[fillcolor=1] + b2[fillcolor=3] + a2->b2->x2 + + // http://www.graphviz.org/doc/info/colors.html + // note: style=filled! + node [shape=box colorscheme=paired12 style=filled] + rankdir=LR + margin=0.1 + c1[fillcolor=1] + c2[fillcolor=2] + c3[fillcolor=3] + c4[fillcolor=4] + c5[fillcolor=5] + c6[fillcolor=6] + c7[fillcolor=7] + c8[fillcolor=8] + c9[fillcolor=9] + c10[fillcolor=10] + c11[fillcolor=11] + c12[fillcolor=12] + c->{c1 c3 c5 c7 c9 c11} + c1->c2 + c3->c4 + c5->c6 + c7->c8 + c9->c10 + c11->c12 +} diff --git a/tests/syntax-tests/highlighted/Graphviz DOT/test_graph.dot b/tests/syntax-tests/highlighted/Graphviz DOT/test_graph.dot new file mode 100644 index 00000000..205c2981 --- /dev/null +++ b/tests/syntax-tests/highlighted/Graphviz DOT/test_graph.dot @@ -0,0 +1,3 @@ +graph { + a--b +} diff --git a/tests/syntax-tests/highlighted/Groovy/test.groovy b/tests/syntax-tests/highlighted/Groovy/test.groovy new file mode 100644 index 00000000..0c648df9 --- /dev/null +++ b/tests/syntax-tests/highlighted/Groovy/test.groovy @@ -0,0 +1,77 @@ +interface Display { + String asText() +} + +trait Entity { + Integer id +} + +class Product implements Entity, Display { + public String name + public Boolean available + public Float price + + private String key + protected String data + + /** + * Creates a new product instance. + * @param id Product ID. + * @param name Product name. + * @param available Product availability. + * @param price Product price. + * @param key Product key. + * @param data Product internal data. + */ + Product(id, name, available, price, key = "key", data = "internal") { + this.id = id + this.name = name + this.available = available + this.price = price + this.key = key + this.data = data + } + + /**@ + * Returns product data as text. + * @return Data string. + */ + String asText() { + return """ID [${id}] Name [${name}] Available [${available}] Price [${price}]""" + } +} + +/* Creates a new product instance */ +def product = new Product(1, "T-Shirt", true, 15.00) + +println(product.asText()) + +product.available = false +product.price = 0.0 + +// Check values +assert product.asText() == "ID [1] Name [T-Shirt] Available [false] Price [0.0]" + +def factorial(Integer value) { + if (value <= 1) { + return 1 + } else { + return value * factorial(value - 1) + } +} + +assert factorial(5) == 120 + +static String join(List list, String separator) { + String data = "" + + list.each { item -> + data += item + separator + } + + data = data.substring(0, data.length() - 1) + + return data +} + +assert join(["g", "r", "o", "o", "v", "y"], " ") == "g r o o v y" diff --git a/tests/syntax-tests/highlighted/HTML/test.html b/tests/syntax-tests/highlighted/HTML/test.html new file mode 100644 index 00000000..3df49d03 --- /dev/null +++ b/tests/syntax-tests/highlighted/HTML/test.html @@ -0,0 +1,115 @@ + +<html> +  + <head> + <title>Bat Syntax Test + <meta charset="utf-8">  + <script> + const x = 'world'; + function logGreeting() { + console.log(`Hello, ${x}`); + } +  +  + <body> + <div> + <h1>Here find some simple tags + <br /> + <p center style="color: rebeccapurple;"> + Lorem <strong>ipsum dolor sit amet consectetur adipisicing + elit. A quo, autem quaerat explicabo impedit mollitia amet molestiae + nulla cum architecto ducimus itaque sit blanditiis quasi animi optio ab + facilis nihil? +  + <p> + Here are some escaped characters: &amp; (ampersand), &agrave; (a with grave), &#8470; (numero sign). +  +  + <div> + <h1>This is a form that demonstrates loose attribute formatting + <form action="POST"> + <input + disabled + type="text" + name="text input" + id="specificTextInput" + value="yes" + /> +  +  + <div> + <h1>A table with normal closing tags + <table> + <caption> + Pet Features +  + <colgroup> + <col /> + <col /> + <col /> +  + <thead> + <tr> + <th>Feature + <th>Cat + <th>Dog +  +  + <tbody> + <tr> + <td>Tail + <td>✔ + <td>✔ +  + <tr> + <td>Eyes + <td>✔ + <td>✔ +  + <tr> + <td>Ears + <td>✔ + <td>✔ +  + <tr> + <td>Barking + <td> + <td>✔ +  + <tr> + <td>Litter Box + <td>✔ + <td> +  +  +  +  + <div> + <h1>A table without closing tags + <table> + <caption>Pet Features + <colgroup><col><col><col> + <thead> + <tr> <th>Feature <th>Cat <th>Dog + <tbody> + <tr> <td>Tail <td>✔ <td>✔ + <tr> <td>Eyes <td>✔ <td>✔ + <tr> <td>Ears <td>✔ <td>✔ + <tr> <td>Barking <td> <td>✔ + <tr> <td>Litter Box <td>✔ <td> +  +  +  + <div> + <h1>A math section with CDATA + <p>You can add a string to a number, but this stringifies the number: + <math> + <ms> + <mo>- + <mn>7 + <mo>= + <ms> +  +  +  + diff --git a/tests/syntax-tests/highlighted/Hosts/hosts b/tests/syntax-tests/highlighted/Hosts/hosts new file mode 100644 index 00000000..8d322f00 --- /dev/null +++ b/tests/syntax-tests/highlighted/Hosts/hosts @@ -0,0 +1,8 @@ +#this is a comment in the hosts file +127.0.0.1  localhost + +192.168.0.1 sample.test #a comment +192.160.0.200 try.sample.test try #another comment +216.58.223.238 google.com + +::1 localhost.try ip6-localhost diff --git a/tests/syntax-tests/highlighted/Lean/test.lean b/tests/syntax-tests/highlighted/Lean/test.lean new file mode 100644 index 00000000..51918c6a --- /dev/null +++ b/tests/syntax-tests/highlighted/Lean/test.lean @@ -0,0 +1,68 @@ +import data.matrix.notation +import data.vector2 + +/-! + +Helpers that don't currently fit elsewhere... + +-/ + +lemma split_eq {m n : Type*} (x : m × n) (p p' : m × n) : + p = x ∨ p' = x ∨ (x ≠ p ∧ x ≠ p') := by tauto + +-- For `playfield`s, the piece type and/or piece index type. +variables (X : Type*) +variables [has_repr X] + +namespace chess.utils + +section repr + +/-- +An auxiliary wrapper for `option X` that allows for overriding the `has_repr` instance +for `option`, and rather, output just the value in the `some` and a custom provided +`string` for `none`. +-/ +structure option_wrapper := +(val : option X) +(none_s : string) + +instance wrapped_option_repr : has_repr (option_wrapper X) := +⟨λ ⟨val, s⟩, (option.map has_repr.repr val).get_or_else s⟩ + +variables {X} +/-- +Construct an `option_wrapper` term from a provided `option X` and the `string` +that will override the `has_repr.repr` for `none`. +-/ +def option_wrap (val : option X) (none_s : string) : option_wrapper X := ⟨val, none_s⟩ + +-- The size of the "vectors" for a `fin n' → X`, for `has_repr` definitions +variables {m' n' : ℕ} + +/-- +For a "vector" `X^n'` represented by the type `Π n' : ℕ, fin n' → X`, where +the `X` has a `has_repr` instance itself, we can provide a `has_repr` for the "vector". +This definition is used for displaying rows of the playfield, when it is defined +via a `matrix`, likely through notation. +-/ +def vec_repr : Π {n' : ℕ}, (fin n' → X) → string := +λ _ v, string.intercalate ", " ((vector.of_fn v).to_list.map repr) + +instance vec_repr_instance : has_repr (fin n' → X) := ⟨vec_repr⟩ + +/-- +For a `matrix` `X^(m' × n')` where the `X` has a `has_repr` instance itself, +we can provide a `has_repr` for the matrix, using `vec_repr` for each of the rows of the matrix. +This definition is used for displaying the playfield, when it is defined +via a `matrix`, likely through notation. +-/ +def matrix_repr : Π {m' n'}, matrix (fin m') (fin n') X → string := +λ _ _ M, string.intercalate ";\n" ((vector.of_fn M).to_list.map repr) + +instance matrix_repr_instance : + has_repr (matrix (fin n') (fin m') X) := ⟨matrix_repr⟩ + +end repr + +end chess.utils diff --git a/tests/syntax-tests/highlighted/Lisp/utils.lisp b/tests/syntax-tests/highlighted/Lisp/utils.lisp new file mode 100644 index 00000000..ef61a820 --- /dev/null +++ b/tests/syntax-tests/highlighted/Lisp/utils.lisp @@ -0,0 +1,80 @@ +(cl:defpackage :chillax.utils + (:use :cl :alexandria) + (:export + :fun :mkhash :hashget :strcat :dequote :at)) +(in-package :chillax.utils) + +;;; Functions +(defmacro fun (&body body) + "This macro puts the FUN back in FUNCTION." + `(lambda (&optional _) (declare (ignorable _)) ,@body)) + +;;; Hash tables +(defun mkhash (&rest keys-and-values &aux (table (make-hash-table :test #'equal))) + "Convenience function for `literal' hash table definition." + (loop for (key val) on keys-and-values by #'cddr do (setf (gethash key table) val) + finally (return table))) + +(defun hashget (hash &rest keys) + "Convenience function for recursively accessing hash tables." + (reduce (lambda (h k) (gethash k h)) keys :initial-value hash)) + +(define-compiler-macro hashget (hash &rest keys) + (if (null keys) hash + (let ((hash-sym (make-symbol "HASH")) + (key-syms (loop for i below (length keys) + collect (make-symbol (format nil "~:@(~:R~)-KEY" i))))) + `(let ((,hash-sym ,hash) + ,@(loop for key in keys for sym in key-syms + collect `(,sym ,key))) + ,(reduce (lambda (hash key) `(gethash ,key ,hash)) + key-syms :initial-value hash-sym))))) + +(defun (setf hashget) (new-value hash key &rest more-keys) + "Uses the last key given to hashget to insert NEW-VALUE into the hash table +returned by the second-to-last key. +tl;dr: DWIM SETF function for HASHGET." + (if more-keys + (setf (gethash (car (last more-keys)) + (apply #'hashget hash key (butlast more-keys))) + new-value) + (setf (gethash key hash) new-value))) + +;;; Strings +(defun strcat (string &rest more-strings) + (apply #'concatenate 'string string more-strings)) + +(defun dequote (string) + (let ((len (length string))) + (if (and (> len 1) (starts-with #\" string) (ends-with #\" string)) + (subseq string 1 (- len 1)) + string))) + +;;; +;;; At +;;; +(defgeneric at (doc &rest keys)) +(defgeneric (setf at) (new-value doc key &rest more-keys)) + +(defmethod at ((doc hash-table) &rest keys) + (apply #'hashget doc keys)) +(defmethod (setf at) (new-value (doc hash-table) key &rest more-keys) + (apply #'(setf hashget) new-value doc key more-keys)) + +(defmethod at ((doc list) &rest keys) + (reduce (lambda (alist key) + (cdr (assoc key alist :test #'equal))) + keys :initial-value doc)) +(defmethod (setf at) (new-value (doc list) key &rest more-keys) + (if more-keys + (setf (cdr (assoc (car (last more-keys)) + (apply #'at doc key (butlast more-keys)) + :test #'equal)) + new-value) + (setf (cdr (assoc key doc :test #'equal)) new-value))) + +;; A playful alias. +(defun @ (doc &rest keys) + (apply #'at doc keys)) +(defun (setf @) (new-value doc key &rest more-keys) + (apply #'(setf at) new-value doc key more-keys)) diff --git a/tests/syntax-tests/highlighted/Lua/test.lua b/tests/syntax-tests/highlighted/Lua/test.lua new file mode 100644 index 00000000..3c37aeee --- /dev/null +++ b/tests/syntax-tests/highlighted/Lua/test.lua @@ -0,0 +1,34 @@ +--- Finds factorial of a number. +-- @param value Number to find factorial. +-- @return Factorial of number. +local function factorial(value) + if value <= 1 then + return 1 + else + return value * factorial(value - 1) + end +end + +--- Joins a table of strings into a new string. +-- @param table Table of strings. +-- @param separator Separator character. +-- @return Joined string. +local function join(table, separator) + local data = "" +  + for index, value in ipairs(table) do + data = data .. value .. separator + end +  + data = data:sub(1, data:len() - 1) +  + return data +end + +local a = factorial(5) + +print(a) + +local b = join({ "l", "u", "a" }, ",") + +print(b) diff --git a/tests/syntax-tests/highlighted/MATLAB/test.matlab b/tests/syntax-tests/highlighted/MATLAB/test.matlab new file mode 100644 index 00000000..51c37f76 --- /dev/null +++ b/tests/syntax-tests/highlighted/MATLAB/test.matlab @@ -0,0 +1,34 @@ +function zz=sample(aa) +%%%%%%%%%%%%%%%%%% +% some comments +%%%%%%%%%%%%%%%%%% + +x = 'a string'; % some 'ticks' in a comment +y = 'a string with ''interal'' quotes'; + +for i=1:20 + disp(i); +end + +a = rand(30); +b = rand(30); + +c = a .* b ./ a \ ... comment at end of line and continuation + (b .* a + b - a); + +c = a' * b'; % note: these ticks are for transpose, not quotes. + +disp('a comment symbol, %, in a string'); + +!echo abc % this isn't a comment - it's passed to system command + +function y=myfunc(x) +y = exp(x); + +%{ + a block comment +%} + +function no_arg_func +fprintf('%s\n', 'function with no args') +end diff --git a/tests/syntax-tests/highlighted/Makefile/Makefile b/tests/syntax-tests/highlighted/Makefile/Makefile new file mode 100644 index 00000000..dc4d36fc --- /dev/null +++ b/tests/syntax-tests/highlighted/Makefile/Makefile @@ -0,0 +1,385 @@ +# Redis Makefile +# Copyright (C) 2009 Salvatore Sanfilippo  +# This file is released under the BSD license, see the COPYING file +# +# The Makefile composes the final FINAL_CFLAGS and FINAL_LDFLAGS using +# what is needed for Redis plus the standard CFLAGS and LDFLAGS passed. +# However when building the dependencies (Jemalloc, Lua, Hiredis, ...) +# CFLAGS and LDFLAGS are propagated to the dependencies, so to pass +# flags only to be used when compiling / linking Redis itself REDIS_CFLAGS +# and REDIS_LDFLAGS are used instead (this is the case of 'make gcov'). +# +# Dependencies are stored in the Makefile.dep file. To rebuild this file +# Just use 'make dep', but this is only needed by developers. + +release_hdr := $(shell sh -c './mkreleasehdr.sh') +uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') +uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not') +OPTIMIZATION?=-O2 +DEPENDENCY_TARGETS=hiredis linenoise lua +NODEPS:=clean distclean + +# Default settings +STD=-std=c11 -pedantic -DREDIS_STATIC='' +ifneq (,$(findstring clang,$(CC))) +ifneq (,$(findstring FreeBSD,$(uname_S))) + STD+=-Wno-c11-extensions +endif +endif +WARN=-Wall -W -Wno-missing-field-initializers +OPT=$(OPTIMIZATION) + +PREFIX?=/usr/local +INSTALL_BIN=$(PREFIX)/bin +INSTALL=install +PKG_CONFIG?=pkg-config + +# Default allocator defaults to Jemalloc if it's not an ARM +MALLOC=libc +ifneq ($(uname_M),armv6l) +ifneq ($(uname_M),armv7l) +ifeq ($(uname_S),Linux) + MALLOC=jemalloc +endif +endif +endif + +# To get ARM stack traces if Redis crashes we need a special C flag. +ifneq (,$(filter aarch64 armv,$(uname_M))) + CFLAGS+=-funwind-tables +else +ifneq (,$(findstring armv,$(uname_M))) + CFLAGS+=-funwind-tables +endif +endif + +# Backwards compatibility for selecting an allocator +ifeq ($(USE_TCMALLOC),yes) + MALLOC=tcmalloc +endif + +ifeq ($(USE_TCMALLOC_MINIMAL),yes) + MALLOC=tcmalloc_minimal +endif + +ifeq ($(USE_JEMALLOC),yes) + MALLOC=jemalloc +endif + +ifeq ($(USE_JEMALLOC),no) + MALLOC=libc +endif + +# Override default settings if possible +-include .make-settings + +FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS) +FINAL_LDFLAGS=$(LDFLAGS) $(REDIS_LDFLAGS) $(DEBUG) +FINAL_LIBS=-lm +DEBUG=-g -ggdb + +# Linux ARM needs -latomic at linking time +ifneq (,$(filter aarch64 armv,$(uname_M))) + FINAL_LIBS+=-latomic +else +ifneq (,$(findstring armv,$(uname_M))) + FINAL_LIBS+=-latomic +endif +endif + +ifeq ($(uname_S),SunOS) + # SunOS + ifneq ($(@@),32bit) + CFLAGS+= -m64 + LDFLAGS+= -m64 + endif + DEBUG=-g + DEBUG_FLAGS=-g + export CFLAGS LDFLAGS DEBUG DEBUG_FLAGS + INSTALL=cp -pf + FINAL_CFLAGS+= -D__EXTENSIONS__ -D_XPG6 + FINAL_LIBS+= -ldl -lnsl -lsocket -lresolv -lpthread -lrt +else +ifeq ($(uname_S),Darwin) + # Darwin + FINAL_LIBS+= -ldl + OPENSSL_CFLAGS=-I/usr/local/opt/openssl/include + OPENSSL_LDFLAGS=-L/usr/local/opt/openssl/lib +else +ifeq ($(uname_S),AIX) + # AIX + FINAL_LDFLAGS+= -Wl,-bexpall + FINAL_LIBS+=-ldl -pthread -lcrypt -lbsd +else +ifeq ($(uname_S),OpenBSD) + # OpenBSD + FINAL_LIBS+= -lpthread + ifeq ($(USE_BACKTRACE),yes) + FINAL_CFLAGS+= -DUSE_BACKTRACE -I/usr/local/include + FINAL_LDFLAGS+= -L/usr/local/lib + FINAL_LIBS+= -lexecinfo + endif + +else +ifeq ($(uname_S),FreeBSD) + # FreeBSD + FINAL_LIBS+= -lpthread -lexecinfo +else +ifeq ($(uname_S),DragonFly) + # FreeBSD + FINAL_LIBS+= -lpthread -lexecinfo +else +ifeq ($(uname_S),OpenBSD) + # OpenBSD + FINAL_LIBS+= -lpthread -lexecinfo +else +ifeq ($(uname_S),NetBSD) + # NetBSD + FINAL_LIBS+= -lpthread -lexecinfo +else + # All the other OSes (notably Linux) + FINAL_LDFLAGS+= -rdynamic + FINAL_LIBS+=-ldl -pthread -lrt +endif +endif +endif +endif +endif +endif +endif +endif +# Include paths to dependencies +FINAL_CFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src + +# Determine systemd support and/or build preference (defaulting to auto-detection) +BUILD_WITH_SYSTEMD=no +# If 'USE_SYSTEMD' in the environment is neither "no" nor "yes", try to +# auto-detect libsystemd's presence and link accordingly. +ifneq ($(USE_SYSTEMD),no) + LIBSYSTEMD_PKGCONFIG := $(shell $(PKG_CONFIG) --exists libsystemd && echo $$?) +# If libsystemd cannot be detected, continue building without support for it +# (unless a later check tells us otherwise) +ifeq ($(LIBSYSTEMD_PKGCONFIG),0) + BUILD_WITH_SYSTEMD=yes +endif +endif +ifeq ($(USE_SYSTEMD),yes) +ifneq ($(LIBSYSTEMD_PKGCONFIG),0) +$(error USE_SYSTEMD is set to "$(USE_SYSTEMD)", but $(PKG_CONFIG) cannot find libsystemd) +endif +# Force building with libsystemd + BUILD_WITH_SYSTEMD=yes +endif +ifeq ($(BUILD_WITH_SYSTEMD),yes) + FINAL_LIBS+=$(shell $(PKG_CONFIG) --libs libsystemd) + FINAL_CFLAGS+= -DHAVE_LIBSYSTEMD +endif + +ifeq ($(MALLOC),tcmalloc) + FINAL_CFLAGS+= -DUSE_TCMALLOC + FINAL_LIBS+= -ltcmalloc +endif + +ifeq ($(MALLOC),tcmalloc_minimal) + FINAL_CFLAGS+= -DUSE_TCMALLOC + FINAL_LIBS+= -ltcmalloc_minimal +endif + +ifeq ($(MALLOC),jemalloc) + DEPENDENCY_TARGETS+= jemalloc + FINAL_CFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include + FINAL_LIBS := ../deps/jemalloc/lib/libjemalloc.a $(FINAL_LIBS) +endif + +ifeq ($(BUILD_TLS),yes) + FINAL_CFLAGS+=-DUSE_OPENSSL $(OPENSSL_CFLAGS) + FINAL_LDFLAGS+=$(OPENSSL_LDFLAGS) + LIBSSL_PKGCONFIG := $(shell $(PKG_CONFIG) --exists libssl && echo $$?) +ifeq ($(LIBSSL_PKGCONFIG),0) + LIBSSL_LIBS=$(shell $(PKG_CONFIG) --libs libssl) +else + LIBSSL_LIBS=-lssl +endif + LIBCRYPTO_PKGCONFIG := $(shell $(PKG_CONFIG) --exists libcrypto && echo $$?) +ifeq ($(LIBCRYPTO_PKGCONFIG),0) + LIBCRYPTO_LIBS=$(shell $(PKG_CONFIG) --libs libcrypto) +else + LIBCRYPTO_LIBS=-lcrypto +endif + FINAL_LIBS += ../deps/hiredis/libhiredis_ssl.a $(LIBSSL_LIBS) $(LIBCRYPTO_LIBS) +endif + +REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS) +REDIS_LD=$(QUIET_LINK)$(CC) $(FINAL_LDFLAGS) +REDIS_INSTALL=$(QUIET_INSTALL)$(INSTALL) + +CCCOLOR="\033[34m" +LINKCOLOR="\033[34;1m" +SRCCOLOR="\033[33m" +BINCOLOR="\033[37;1m" +MAKECOLOR="\033[32;1m" +ENDCOLOR="\033[0m" + +ifndef V +QUIET_CC = @printf ' %b %b\n' $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR) 1>&2; +QUIET_LINK = @printf ' %b %b\n' $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2; +QUIET_INSTALL = @printf ' %b %b\n' $(LINKCOLOR)INSTALL$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2; +endif + +REDIS_SERVER_NAME=redis-server +REDIS_SENTINEL_NAME=redis-sentinel +REDIS_SERVER_OBJ=adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crcspeed.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o lolwut.o lolwut5.o lolwut6.o acl.o gopher.o tracking.o connection.o tls.o sha256.o timeout.o setcpuaffinity.o +REDIS_CLI_NAME=redis-cli +REDIS_CLI_OBJ=anet.o adlist.o dict.o redis-cli.o zmalloc.o release.o ae.o crcspeed.o crc64.o siphash.o crc16.o +REDIS_BENCHMARK_NAME=redis-benchmark +REDIS_BENCHMARK_OBJ=ae.o anet.o redis-benchmark.o adlist.o dict.o zmalloc.o siphash.o +REDIS_CHECK_RDB_NAME=redis-check-rdb +REDIS_CHECK_AOF_NAME=redis-check-aof + +all: $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCHMARK_NAME) $(REDIS_CHECK_RDB_NAME) $(REDIS_CHECK_AOF_NAME) + @echo "" + @echo "Hint: It's a good idea to run 'make test' ;)" + @echo "" + +Makefile.dep: + -$(REDIS_CC) -MM *.c > Makefile.dep 2> /dev/null || true + +ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS)))) +-include Makefile.dep +endif + +.PHONY: all + +persist-settings: distclean + echo STD=$(STD) >> .make-settings + echo WARN=$(WARN) >> .make-settings + echo OPT=$(OPT) >> .make-settings + echo MALLOC=$(MALLOC) >> .make-settings + echo BUILD_TLS=$(BUILD_TLS) >> .make-settings + echo USE_SYSTEMD=$(USE_SYSTEMD) >> .make-settings + echo CFLAGS=$(CFLAGS) >> .make-settings + echo LDFLAGS=$(LDFLAGS) >> .make-settings + echo REDIS_CFLAGS=$(REDIS_CFLAGS) >> .make-settings + echo REDIS_LDFLAGS=$(REDIS_LDFLAGS) >> .make-settings + echo PREV_FINAL_CFLAGS=$(FINAL_CFLAGS) >> .make-settings + echo PREV_FINAL_LDFLAGS=$(FINAL_LDFLAGS) >> .make-settings + -(cd ../deps && $(MAKE) $(DEPENDENCY_TARGETS)) + +.PHONY: persist-settings + +# Prerequisites target +.make-prerequisites: + @touch $@ + +# Clean everything, persist settings and build dependencies if anything changed +ifneq ($(strip $(PREV_FINAL_CFLAGS)), $(strip $(FINAL_CFLAGS))) +.make-prerequisites: persist-settings +endif + +ifneq ($(strip $(PREV_FINAL_LDFLAGS)), $(strip $(FINAL_LDFLAGS))) +.make-prerequisites: persist-settings +endif + +# redis-server +$(REDIS_SERVER_NAME): $(REDIS_SERVER_OBJ) + $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/lua/src/liblua.a $(FINAL_LIBS) + +# redis-sentinel +$(REDIS_SENTINEL_NAME): $(REDIS_SERVER_NAME) + $(REDIS_INSTALL) $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) + +# redis-check-rdb +$(REDIS_CHECK_RDB_NAME): $(REDIS_SERVER_NAME) + $(REDIS_INSTALL) $(REDIS_SERVER_NAME) $(REDIS_CHECK_RDB_NAME) + +# redis-check-aof +$(REDIS_CHECK_AOF_NAME): $(REDIS_SERVER_NAME) + $(REDIS_INSTALL) $(REDIS_SERVER_NAME) $(REDIS_CHECK_AOF_NAME) + +# redis-cli +$(REDIS_CLI_NAME): $(REDIS_CLI_OBJ) + $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o $(FINAL_LIBS) + +# redis-benchmark +$(REDIS_BENCHMARK_NAME): $(REDIS_BENCHMARK_OBJ) + $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a $(FINAL_LIBS) + +dict-benchmark: dict.c zmalloc.c sds.c siphash.c + $(REDIS_CC) $(FINAL_CFLAGS) $^ -D DICT_BENCHMARK_MAIN -o $@ $(FINAL_LIBS) + +DEP = $(REDIS_SERVER_OBJ:%.o=%.d) $(REDIS_CLI_OBJ:%.o=%.d) $(REDIS_BENCHMARK_OBJ:%.o=%.d) +-include $(DEP) + +# Because the jemalloc.h header is generated as a part of the jemalloc build, +# building it should complete before building any other object. Instead of +# depending on a single artifact, build all dependencies first. +%.o: %.c .make-prerequisites + $(REDIS_CC) -MMD -o $@ -c $< + +clean: + rm -rf $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCHMARK_NAME) $(REDIS_CHECK_RDB_NAME) $(REDIS_CHECK_AOF_NAME) *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep dict-benchmark + rm -f $(DEP) + +.PHONY: clean + +distclean: clean + -(cd ../deps && $(MAKE) distclean) + -(rm -f .make-*) + +.PHONY: distclean + +test: $(REDIS_SERVER_NAME) $(REDIS_CHECK_AOF_NAME) + @(cd ..; ./runtest) + +test-sentinel: $(REDIS_SENTINEL_NAME) + @(cd ..; ./runtest-sentinel) + +check: test + +lcov: + $(MAKE) gcov + @(set -e; cd ..; ./runtest --clients 1) + @geninfo -o redis.info . + @genhtml --legend -o lcov-html redis.info + +test-sds: sds.c sds.h + $(REDIS_CC) sds.c zmalloc.c -DSDS_TEST_MAIN $(FINAL_LIBS) -o /tmp/sds_test + /tmp/sds_test + +.PHONY: lcov + +bench: $(REDIS_BENCHMARK_NAME) + ./$(REDIS_BENCHMARK_NAME) + +32bit: + @echo "" + @echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386" + @echo "" + $(MAKE) CFLAGS="-m32" LDFLAGS="-m32" + +gcov: + $(MAKE) REDIS_CFLAGS="-fprofile-arcs -ftest-coverage -DCOVERAGE_TEST" REDIS_LDFLAGS="-fprofile-arcs -ftest-coverage" + +noopt: + $(MAKE) OPTIMIZATION="-O0" + +valgrind: + $(MAKE) OPTIMIZATION="-O0" MALLOC="libc" + +helgrind: + $(MAKE) OPTIMIZATION="-O0" MALLOC="libc" CFLAGS="-D__ATOMIC_VAR_FORCE_SYNC_MACROS" + +src/help.h: + @../utils/generate-command-help.rb > help.h + +install: all + @mkdir -p $(INSTALL_BIN) + $(REDIS_INSTALL) $(REDIS_SERVER_NAME) $(INSTALL_BIN) + $(REDIS_INSTALL) $(REDIS_BENCHMARK_NAME) $(INSTALL_BIN) + $(REDIS_INSTALL) $(REDIS_CLI_NAME) $(INSTALL_BIN) + $(REDIS_INSTALL) $(REDIS_CHECK_RDB_NAME) $(INSTALL_BIN) + $(REDIS_INSTALL) $(REDIS_CHECK_AOF_NAME) $(INSTALL_BIN) + @ln -sf $(REDIS_SERVER_NAME) $(INSTALL_BIN)/$(REDIS_SENTINEL_NAME) + +uninstall: + rm -f $(INSTALL_BIN)/{$(REDIS_SERVER_NAME),$(REDIS_BENCHMARK_NAME),$(REDIS_CLI_NAME),$(REDIS_CHECK_RDB_NAME),$(REDIS_CHECK_AOF_NAME),$(REDIS_SENTINEL_NAME)} diff --git a/tests/syntax-tests/highlighted/Manpage/bat-0.16.man b/tests/syntax-tests/highlighted/Manpage/bat-0.16.man new file mode 100644 index 00000000..92485f84 --- /dev/null +++ b/tests/syntax-tests/highlighted/Manpage/bat-0.16.man @@ -0,0 +1,243 @@ +BAT(1) General Commands Manual BAT(1) + +NAME + bat - a cat(1) clone with syntax highlighting and Git integration. + +USAGE + bat [OPTIONS] [FILE]... + + bat cache [CACHE-OPTIONS] [--build|--clear] + +DESCRIPTION + bat prints the syntax-highlighted content of a collection of FILEs to + the terminal. If no FILE is specified, or when FILE is '-', it reads + from standard input. + + bat supports a large number of programming and markup languages. It + also communicates with git(1) to show modifications with respect to the + git index. bat automatically pipes its output through a pager (by de‐ + fault: less). + + Whenever the output of bat goes to a non-interactive terminal, i.e. + when the output is piped into another process or into a file, bat will + act as a drop-in replacement for cat(1) and fall back to printing the + plain file contents. + +OPTIONS + General remarks: Command-line options like '-l'/'--language' that take + values can be specified as either '--language value', '--lan‐ + guage=value', '-l value' or '-lvalue'. + + -A, --show-all + + Show non-printable characters like space, tab or newline. Use + '--tabs' to control the width of the tab-placeholders. + + -p, --plain + + Only show plain style, no decorations. This is an alias for + '--style=plain'. When '-p' is used twice ('-pp'), it also dis‐ + ables automatic paging (alias for '--style=plain + --pager=never'). + + -l, --language <language> + + Explicitly set the language for syntax highlighting. The lan‐ + guage can be specified as a name (like 'C++' or 'LaTeX') or pos‐ + sible file extension (like 'cpp', 'hpp' or 'md'). Use + '--list-languages' to show all supported language names and file + extensions. + + -H, --highlight-line ... + + Highlight the specified line ranges with a different background + color For example: + + --highlight-line 40 + highlights line 40 + + --highlight-line 30:40 + highlights lines 30 to 40 + + --highlight-line :40 + highlights lines 1 to 40 + + --highlight-line 40: + highlights lines 40 to the end of the file + + --tabs <T> + + Set the tab width to T spaces. Use a width of 0 to pass tabs + through directly + + --wrap <mode> + + Specify the text-wrapping mode (*auto*, never, character). The + '--terminal-width' option can be used in addition to control the + output width. + + --terminal-width <width> + + Explicitly set the width of the terminal instead of determining + it automatically. If prefixed with '+' or '-', the value will be + treated as an offset to the actual terminal width. See also: + '--wrap'. + + -n, --number + + Only show line numbers, no other decorations. This is an alias + for '--style=numbers' + + --color <when> + + Specify when to use colored output. The automatic mode only en‐ + ables colors if an interactive terminal is detected. Possible + values: *auto*, never, always. + + --italic-text <when> + + Specify when to use ANSI sequences for italic text in the out‐ + put. Possible values: always, *never*. + + --decorations <when> + + Specify when to use the decorations that have been specified via + '--style'. The automatic mode only enables decorations if an in‐ + teractive terminal is detected. Possible values: *auto*, never, + always. + + -f, --force-colorization + + Alias for '--decorations=always --color=always'. This is useful + if the output of bat is piped to another program, but you want + to keep the colorization/decorations. + + --paging <when> + + Specify when to use the pager. To disable the pager, use '--pag‐ + ing=never' or its alias, -P. To disable the pager permanently, + set BAT_PAGER to an empty string. To control which pager is + used, see the '--pager' option. Possible values: *auto*, never, + always. + + --pager <command> + + Determine which pager is used. This option will override the + PAGER and BAT_PAGER environment variables. The default pager is + 'less'. To control when the pager is used, see the '--paging' + option. Example: '--pager "less -RF"'. + + -m, --map-syntax ... + + Map a glob pattern to an existing syntax name. The glob pattern + is matched on the full path and the filename. For example, to + highlight *.build files with the Python syntax, use -m + '*.build:Python'. To highlight files named '.myignore' with the + Git Ignore syntax, use -m '.myignore:Git Ignore'. + + --theme <theme> + + Set the theme for syntax highlighting. Use '--list-themes' to + see all available themes. To set a default theme, add the + '--theme="..."' option to the configuration file or export the + BAT_THEME environment variable (e.g.: export BAT_THEME="..."). + + --list-themes + + Display a list of supported themes for syntax highlighting. + + --style <style-components> + + Configure which elements (line numbers, file headers, grid bor‐ + ders, Git modifications, ..) to display in addition to the file + contents. The argument is a comma-separated list of components + to display (e.g. 'numbers,changes,grid') or a pre-defined style + ('full'). To set a default style, add the '--style=".."' option + to the configuration file or export the BAT_STYLE environment + variable (e.g.: export BAT_STYLE=".."). Possible values: *auto*, + full, plain, changes, header, grid, numbers, snip. + + -r, --line-range ... + + Only print the specified range of lines for each file. For exam‐ + ple: + + --line-range 30:40 + prints lines 30 to 40 + + --line-range :40 + prints lines 1 to 40 + + --line-range 40: + prints lines 40 to the end of the file + + -L, --list-languages + + Display a list of supported languages for syntax highlighting. + + -u, --unbuffered + + This option exists for POSIX-compliance reasons ('u' is for 'un‐ + buffered'). The output is always unbuffered - this option is + simply ignored. + + -h, --help + + Print this help message. + + -V, --version + + Show version information. + +POSITIONAL ARGUMENTS + ... + + Files to print and concatenate. Use a dash ('-') or no argument + at all to read from standard input. + +SUBCOMMANDS + cache - Modify the syntax-definition and theme cache. + +FILES + bat can also be customized with a configuration file. The location of + the file is dependent on your operating system. To get the default path + for your system, call: + + bat --config-file + + Alternatively, you can use the BAT_CONFIG_PATH environment variable to + point bat to a non-default location of the configuration file. + +ADDING CUSTOM LANGUAGES + bat supports Sublime Text .sublime-syntax language files, and can be + customized to add additional languages to your local installation. To + do this, add the .sublime-snytax language files to `$(bat --config- + dir)/syntaxes` and run `bat cache --build`. + + Example: + + mkdir -p "$(bat --config-dir)/syntaxes" + cd "$(bat --config-dir)/syntaxes" + + # Put new '.sublime-syntax' language definition files + # in this folder (or its subdirectories), for example: + git clone https://github.com/tellnobody1/sublime-purescript-syntax + + # And then build the cache. + bat cache --build + + Once the cache is built, the new language will be visible in `bat + --list-languages`. + If you ever want to remove the custom languages, you can clear the + cache with `bat cache --clear`. + +ADDING CUSTOM THEMES + Similarly to custom languages, bat supports Sublime Text .tmTheme + themes. These can be installed to `$(bat --config-dir)/themes`, and + are added to the cache with `bat cache --build`. + +MORE INFORMATION + For more information and up-to-date documentation, visit the bat repo: + https://github.com/sharkdp/bat + + BAT(1) diff --git a/tests/syntax-tests/highlighted/Manpage/select-2.man b/tests/syntax-tests/highlighted/Manpage/select-2.man new file mode 100644 index 00000000..a746c365 --- /dev/null +++ b/tests/syntax-tests/highlighted/Manpage/select-2.man @@ -0,0 +1,330 @@ +SELECT(2) Linux Programmer's Manual SELECT(2) + +NAME + select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO - synchronous I/O multiplexing + +SYNOPSIS + #include <sys/select.h> + + int select(int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, struct timeval *timeout); + + void FD_CLR(int fd, fd_set *set); + int FD_ISSET(int fd, fd_set *set); + void FD_SET(int fd, fd_set *set); + void FD_ZERO(fd_set *set); + + int pselect(int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, const struct timespec *timeout, + const sigset_t *sigmask); + + Feature Test Macro Requirements for glibc (see feature_test_macros(7)): + + pselect(): _POSIX_C_SOURCE >= 200112L + +DESCRIPTION + select() allows a program to monitor multiple file descriptors, waiting until one or more of the file descriptors become + "ready" for some class of I/O operation (e.g., input possible). A file descriptor is considered ready if it is possible to + perform a corresponding I/O operation (e.g., read(2), or a sufficiently small write(2)) without blocking. + + select() can monitor only file descriptors numbers that are less than FD_SETSIZE; poll(2) and epoll(7) do not have this limi‐ + tation. See BUGS. + + File descriptor sets + The principal arguments of select() are three "sets" of file descriptors (declared with the type fd_set), which allow the + caller to wait for three classes of events on the specified set of file descriptors. Each of the fd_set arguments may be + specified as NULL if no file descriptors are to be watched for the corresponding class of events. + + Note well: Upon return, each of the file descriptor sets is modified in place to indicate which file descriptors are currently + "ready". Thus, if using select() within a loop, the sets must be reinitialized before each call. The implementation of the + fd_set arguments as value-result arguments is a design error that is avoided in poll(2) and epoll(7). + + The contents of a file descriptor set can be manipulated using the following macros: + + FD_ZERO() + This macro clears (removes all file descriptors from) set. It should be employed as the first step in initializing a + file descriptor set. + + FD_SET() + This macro adds the file descriptor fd to set. Adding a file descriptor that is already present in the set is a no-op, + and does not produce an error. + + FD_CLR() + This macro removes the file descriptor fd from set. Removing a file descriptor that is not present in the set is a no- + op, and does not produce an error. + + FD_ISSET() + select() modifies the contents of the sets according to the rules described below. After calling select(), the FD_IS‐ + SET() macro can be used to test if a file descriptor is still present in a set. FD_ISSET() returns nonzero if the file + descriptor fd is present in set, and zero if it is not. + + Arguments + The arguments of select() are as follows: + + readfds + The file descriptors in this set are watched to see if they are ready for reading. A file descriptor is ready for + reading if a read operation will not block; in particular, a file descriptor is also ready on end-of-file. + + After select() has returned, readfds will be cleared of all file descriptors except for those that are ready for read‐ + ing. + + writefds + The file descriptors in this set are watched to see if they are ready for writing. A file descriptor is ready for + writing if a write operation will not block. However, even if a file descriptor indicates as writable, a large write + may still block. + + After select() has returned, writefds will be cleared of all file descriptors except for those that are ready for writ‐ + ing. + + exceptfds + The file descriptors in this set are watched for "exceptional conditions". For examples of some exceptional condi‐ + tions, see the discussion of POLLPRI in poll(2). + + After select() has returned, exceptfds will be cleared of all file descriptors except for those for which an excep‐ + tional condition has occurred. + + nfds This argument should be set to the highest-numbered file descriptor in any of the three sets, plus 1. The indicated + file descriptors in each set are checked, up to this limit (but see BUGS). + + timeout + The timeout argument is a timeval structure (shown below) that specifies the interval that select() should block wait‐ + ing for a file descriptor to become ready. The call will block until either: + + • a file descriptor becomes ready; + + • the call is interrupted by a signal handler; or + + • the timeout expires. + + Note that the timeout interval will be rounded up to the system clock granularity, and kernel scheduling delays mean + that the blocking interval may overrun by a small amount. + + If both fields of the timeval structure are zero, then select() returns immediately. (This is useful for polling.) + + If timeout is specified as NULL, select() blocks indefinitely waiting for a file descriptor to become ready. + + pselect() + The pselect() system call allows an application to safely wait until either a file descriptor becomes ready or until a signal + is caught. + + The operation of select() and pselect() is identical, other than these three differences: + + • select() uses a timeout that is a struct timeval (with seconds and microseconds), while pselect() uses a struct timespec + (with seconds and nanoseconds). + + • select() may update the timeout argument to indicate how much time was left. pselect() does not change this argument. + + • select() has no sigmask argument, and behaves as pselect() called with NULL sigmask. + + sigmask is a pointer to a signal mask (see sigprocmask(2)); if it is not NULL, then pselect() first replaces the current sig‐ + nal mask by the one pointed to by sigmask, then does the "select" function, and then restores the original signal mask. (If + sigmask is NULL, the signal mask is not modified during the pselect() call.) + + Other than the difference in the precision of the timeout argument, the following pselect() call: + + ready = pselect(nfds, &readfds, &writefds, &exceptfds, + timeout, &sigmask); + + is equivalent to atomically executing the following calls: + + sigset_t origmask; + + pthread_sigmask(SIG_SETMASK, &sigmask, &origmask); + ready = select(nfds, &readfds, &writefds, &exceptfds, timeout); + pthread_sigmask(SIG_SETMASK, &origmask, NULL); + + The reason that pselect() is needed is that if one wants to wait for either a signal or for a file descriptor to become ready, + then an atomic test is needed to prevent race conditions. (Suppose the signal handler sets a global flag and returns. Then a + test of this global flag followed by a call of select() could hang indefinitely if the signal arrived just after the test but + just before the call. By contrast, pselect() allows one to first block signals, handle the signals that have come in, then + call pselect() with the desired sigmask, avoiding the race.) + + The timeout + The timeout argument for select() is a structure of the following type: + + struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ + }; + + The corresponding argument for pselect() has the following type: + + struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ + }; + + On Linux, select() modifies timeout to reflect the amount of time not slept; most other implementations do not do this. + (POSIX.1 permits either behavior.) This causes problems both when Linux code which reads timeout is ported to other operating + systems, and when code is ported to Linux that reuses a struct timeval for multiple select()s in a loop without reinitializing + it. Consider timeout to be undefined after select() returns. + +RETURN VALUE + On success, select() and pselect() return the number of file descriptors contained in the three returned descriptor sets (that + is, the total number of bits that are set in readfds, writefds, exceptfds). The return value may be zero if the timeout ex‐ + pired before any file descriptors became ready. + + On error, -1 is returned, and errno is set to indicate the error; the file descriptor sets are unmodified, and timeout becomes + undefined. + +ERRORS + EBADF An invalid file descriptor was given in one of the sets. (Perhaps a file descriptor that was already closed, or one on + which an error has occurred.) However, see BUGS. + + EINTR A signal was caught; see signal(7). + + EINVAL nfds is negative or exceeds the RLIMIT_NOFILE resource limit (see getrlimit(2)). + + EINVAL The value contained within timeout is invalid. + + ENOMEM Unable to allocate memory for internal tables. + +VERSIONS + pselect() was added to Linux in kernel 2.6.16. Prior to this, pselect() was emulated in glibc (but see BUGS). + +CONFORMING TO + select() conforms to POSIX.1-2001, POSIX.1-2008, and 4.4BSD (select() first appeared in 4.2BSD). Generally portable to/from + non-BSD systems supporting clones of the BSD socket layer (including System V variants). However, note that the System V + variant typically sets the timeout variable before returning, but the BSD variant does not. + + pselect() is defined in POSIX.1g, and in POSIX.1-2001 and POSIX.1-2008. + +NOTES + An fd_set is a fixed size buffer. Executing FD_CLR() or FD_SET() with a value of fd that is negative or is equal to or larger + than FD_SETSIZE will result in undefined behavior. Moreover, POSIX requires fd to be a valid file descriptor. + + The operation of select() and pselect() is not affected by the O_NONBLOCK flag. + + On some other UNIX systems, select() can fail with the error EAGAIN if the system fails to allocate kernel-internal resources, + rather than ENOMEM as Linux does. POSIX specifies this error for poll(2), but not for select(). Portable programs may wish + to check for EAGAIN and loop, just as with EINTR. + + The self-pipe trick + On systems that lack pselect(), reliable (and more portable) signal trapping can be achieved using the self-pipe trick. In + this technique, a signal handler writes a byte to a pipe whose other end is monitored by select() in the main program. (To + avoid possibly blocking when writing to a pipe that may be full or reading from a pipe that may be empty, nonblocking I/O is + used when reading from and writing to the pipe.) + + Emulating usleep(3) + Before the advent of usleep(3), some code employed a call to select() with all three sets empty, nfds zero, and a non-NULL + timeout as a fairly portable way to sleep with subsecond precision. + + Correspondence between select() and poll() notifications + Within the Linux kernel source, we find the following definitions which show the correspondence between the readable, + writable, and exceptional condition notifications of select() and the event notifications provided by poll(2) and epoll(7): + + #define POLLIN_SET (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN | + EPOLLHUP | EPOLLERR) + /* Ready for reading */ + #define POLLOUT_SET (EPOLLWRBAND | EPOLLWRNORM | EPOLLOUT | + EPOLLERR) + /* Ready for writing */ + #define POLLEX_SET (EPOLLPRI) + /* Exceptional condition */ + + Multithreaded applications + If a file descriptor being monitored by select() is closed in another thread, the result is unspecified. On some UNIX sys‐ + tems, select() unblocks and returns, with an indication that the file descriptor is ready (a subsequent I/O operation will + likely fail with an error, unless another process reopens file descriptor between the time select() returned and the I/O oper‐ + ation is performed). On Linux (and some other systems), closing the file descriptor in another thread has no effect on se‐ + lect(). In summary, any application that relies on a particular behavior in this scenario must be considered buggy. + + C library/kernel differences + The Linux kernel allows file descriptor sets of arbitrary size, determining the length of the sets to be checked from the + value of nfds. However, in the glibc implementation, the fd_set type is fixed in size. See also BUGS. + + The pselect() interface described in this page is implemented by glibc. The underlying Linux system call is named pselect6(). + This system call has somewhat different behavior from the glibc wrapper function. + + The Linux pselect6() system call modifies its timeout argument. However, the glibc wrapper function hides this behavior by + using a local variable for the timeout argument that is passed to the system call. Thus, the glibc pselect() function does + not modify its timeout argument; this is the behavior required by POSIX.1-2001. + + The final argument of the pselect6() system call is not a sigset_t * pointer, but is instead a structure of the form: + + struct { + const kernel_sigset_t *ss; /* Pointer to signal set */ + size_t ss_len; /* Size (in bytes) of object + pointed to by 'ss' */ + }; + + This allows the system call to obtain both a pointer to the signal set and its size, while allowing for the fact that most ar‐ + chitectures support a maximum of 6 arguments to a system call. See sigprocmask(2) for a discussion of the difference between + the kernel and libc notion of the signal set. + + Historical glibc details + Glibc 2.0 provided an incorrect version of pselect() that did not take a sigmask argument. + + In glibc versions 2.1 to 2.2.1, one must define _GNU_SOURCE in order to obtain the declaration of pselect() from . + +BUGS + POSIX allows an implementation to define an upper limit, advertised via the constant FD_SETSIZE, on the range of file descrip‐ + tors that can be specified in a file descriptor set. The Linux kernel imposes no fixed limit, but the glibc implementation + makes fd_set a fixed-size type, with FD_SETSIZE defined as 1024, and the FD_*() macros operating according to that limit. To + monitor file descriptors greater than 1023, use poll(2) or epoll(7) instead. + + According to POSIX, select() should check all specified file descriptors in the three file descriptor sets, up to the limit + nfds-1. However, the current implementation ignores any file descriptor in these sets that is greater than the maximum file + descriptor number that the process currently has open. According to POSIX, any such file descriptor that is specified in one + of the sets should result in the error EBADF. + + Starting with version 2.1, glibc provided an emulation of pselect() that was implemented using sigprocmask(2) and select(). + This implementation remained vulnerable to the very race condition that pselect() was designed to prevent. Modern versions of + glibc use the (race-free) pselect() system call on kernels where it is provided. + + On Linux, select() may report a socket file descriptor as "ready for reading", while nevertheless a subsequent read blocks. + This could for example happen when data has arrived but upon examination has the wrong checksum and is discarded. There may + be other circumstances in which a file descriptor is spuriously reported as ready. Thus it may be safer to use O_NONBLOCK on + sockets that should not block. + + On Linux, select() also modifies timeout if the call is interrupted by a signal handler (i.e., the EINTR error return). This + is not permitted by POSIX.1. The Linux pselect() system call has the same behavior, but the glibc wrapper hides this behavior + by internally copying the timeout to a local variable and passing that variable to the system call. + +EXAMPLES + #include <stdio.h> + #include <stdlib.h> + #include <sys/select.h> + + int + main(void) + { + fd_set rfds; + struct timeval tv; + int retval; + + /* Watch stdin (fd 0) to see when it has input. */ + + FD_ZERO(&rfds); + FD_SET(0, &rfds); + + /* Wait up to five seconds. */ + + tv.tv_sec = 5; + tv.tv_usec = 0; + + retval = select(1, &rfds, NULL, NULL, &tv); + /* Don't rely on the value of tv now! */ + + if (retval == -1) + perror("select()"); + else if (retval) + printf("Data is available now.\n"); + /* FD_ISSET(0, &rfds) will be true. */ + else + printf("No data within five seconds.\n"); + + exit(EXIT_SUCCESS); + } + +SEE ALSO + accept(2), connect(2), poll(2), read(2), recv(2), restart_syscall(2), send(2), sigprocmask(2), write(2), epoll(7), time(7) + + For a tutorial with discussion and examples, see select_tut(2). + +COLOPHON + This page is part of release 5.08 of the Linux man-pages project. A description of the project, information about reporting + bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. + +Linux 2020-04-11 SELECT(2) diff --git a/tests/syntax-tests/highlighted/MemInfo/test.MemInfo b/tests/syntax-tests/highlighted/MemInfo/test.MemInfo new file mode 100644 index 00000000..7360ad65 --- /dev/null +++ b/tests/syntax-tests/highlighted/MemInfo/test.MemInfo @@ -0,0 +1,53 @@ +MemTotal: 1004892 kB +MemFree: 109424 kB +MemAvailable: 498032 kB +Buffers: 66360 kB +Cached: 448344 kB +SwapCached: 0 kB +Active: 547076 kB +Inactive: 196864 kB +Active(anon): 249956 kB +Inactive(anon): 7328 kB +Active(file): 297120 kB +Inactive(file): 189536 kB +Unevictable: 18516 kB +Mlocked: 18516 kB +SwapTotal: 0 kB +SwapFree: 0 kB +Dirty: 276 kB +Writeback: 0 kB +AnonPages: 247780 kB +Mapped: 168472 kB +Shmem: 19860 kB +KReclaimable: 59128 kB +Slab: 108616 kB +SReclaimable: 59128 kB +SUnreclaim: 49488 kB +KernelStack: 2060 kB +PageTables: 4232 kB +NFS_Unstable: 0 kB +Bounce: 0 kB +WritebackTmp: 0 kB +CommitLimit: 502444 kB +Committed_AS: 678300 kB +VmallocTotal: 34359738367 kB +VmallocUsed: 10756 kB +VmallocChunk: 0 kB +Percpu: 784 kB +HardwareCorrupted: 0 kB +AnonHugePages: 0 kB +ShmemHugePages: 0 kB +ShmemPmdMapped: 0 kB +FileHugePages: 0 kB +FilePmdMapped: 0 kB +CmaTotal: 0 kB +CmaFree: 0 kB +HugePages_Total: 0 +HugePages_Free: 0 +HugePages_Rsvd: 0 +HugePages_Surp: 0 +Hugepagesize: 2048 kB +Hugetlb: 0 kB +DirectMap4k: 118764 kB +DirectMap2M: 929792 kB +DirectMap1G: 0 kB diff --git a/tests/syntax-tests/highlighted/Ninja/test.ninja b/tests/syntax-tests/highlighted/Ninja/test.ninja new file mode 100644 index 00000000..0a78702d --- /dev/null +++ b/tests/syntax-tests/highlighted/Ninja/test.ninja @@ -0,0 +1,6 @@ +cflags = -Wall + +rule cc + command = gcc $cflags -c $in -o $out + +build foo.o: cc foo.c diff --git a/tests/syntax-tests/highlighted/Objective-C++/test.mm b/tests/syntax-tests/highlighted/Objective-C++/test.mm new file mode 100644 index 00000000..51989020 --- /dev/null +++ b/tests/syntax-tests/highlighted/Objective-C++/test.mm @@ -0,0 +1,68 @@ +#import <Foundation/Foundation.h> + +class Hello { + private: + id greeting_text; + + public: + Hello() { + greeting_text = @"Hello, world!"; + } + + Hello(const char* initial_greeting_text) { + greeting_text = [[NSString alloc] initWithUTF8String:initial_greeting_text]; + } + + void say_hello() { + printf("%s\n", [greeting_text UTF8String]); + } +}; + +@interface Greeting : NSObject { + @private + Hello *hello; + +} +- (id)init; +- (void)dealloc; +- (void)sayGreeting; +- (void)sayGreeting:(Hello*)greeting; +@end + +@implementation Greeting +- (id)init { + self = [super init]; + if (self) { + hello = new Hello(); + } + return self; +} + +- (void)dealloc { + delete hello; + [super dealloc]; +} + +- (void)sayGreeting { + hello->say_hello(); +} + +- (void)sayGreeting:(Hello*)greeting { + greeting->say_hello(); +} +@end + +int main() { + + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + Greeting *greeting = [[Greeting alloc] init]; + [greeting sayGreeting]; + + Hello *hello = new Hello("Bonjour, monde!"); + [greeting sayGreeting:hello]; + + delete hello; + [greeting release]; + [pool release]; + return 0; +} diff --git a/tests/syntax-tests/highlighted/Objective-C/test.m b/tests/syntax-tests/highlighted/Objective-C/test.m new file mode 100644 index 00000000..287c7400 --- /dev/null +++ b/tests/syntax-tests/highlighted/Objective-C/test.m @@ -0,0 +1,32 @@ +#import <myClass.h> +@import Foundation +// Single line comments + +/* + * Multi line comment + */ + +int main (int argc, const char * argv[]) { + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + + NSLog(@"Storage size for int : %d \n", sizeof(int)); + NSLog (@"hello world"); + if (NO) + { + NSLog(@"I am never run"); + } else if (0) + { + NSLog(@"I am also never run"); + } else + { + NSLog(@"I print"); + } + + [pool drain]; + return 0; +} + +@implementation MyClass { + long distance; + NSNumber height; +} diff --git a/tests/syntax-tests/highlighted/PHP/test.php b/tests/syntax-tests/highlighted/PHP/test.php new file mode 100644 index 00000000..e5dbb353 --- /dev/null +++ b/tests/syntax-tests/highlighted/PHP/test.php @@ -0,0 +1,111 @@ += 3 || $numberone <=2) && $numberone != 2.5){ + echo "what a number!!!"; +} +if($numberone >= 3 and $numberone <=2 and $numberone != 2.5){ + echo "something is wrong, this is supposed to be impossible"; +} + + +if ($number < 3){ + $languages = array("HTML", "CSS", "JS"); + print_r($languages); + echo $languages[2]; + print $languages[$number]; +} +elseif ($number == 3 ){ + function favMovie() { + echo "JUMAJI"; + return true; + } + favMovie(); +} +else { + switch ($number) { + case 4: + echo "fours"; + break; + default: + echo "I dont know you"; + } +} + +while($number <= 6 ){ + echo $number; + $number++; + $number += 1; +} + +do { + $number++; +} while ($number < 10); + +for ($houses = 0; $houses <= 5; $housees++){ + break; + echo "getting more houses"; +} + + +class Person { + public $name; + public $age; +  + function __construct($name){ + $this->name = $name; + } +  + function __destruct(){ + echo "On my way out"; + } +  + function setName($name) { + $this->name = $name; + } +} + +$doe = new Person("John Do"); +$doe->setName('John Doe'); + + + + + +$ending = 2 > 3 ? "yep" : "nah"; + +?> diff --git a/tests/syntax-tests/highlighted/Pascal/test.pas b/tests/syntax-tests/highlighted/Pascal/test.pas new file mode 100644 index 00000000..40659b86 --- /dev/null +++ b/tests/syntax-tests/highlighted/Pascal/test.pas @@ -0,0 +1,42 @@ +program Hello; +uses crt; + +type str = string[1]; + arr = array[1..20, 1..60] of char; + +var x, y:integer; + carr:arr; + c:char; + +Procedure start; +{comment here} +begin write (' Press enter to begin. '); +readln; +end; + +Function Valid (var choice:char): boolean; +begin  + valid:= false; + case choice of  + '1':valid:= true; + '2': valid:= true; + '3': valid:= true; + '4': valid:= true; + '5': valid:= true; + '6': valid:= true; + end; +end; + +begin + for y:=1 to 3 do + begin + writeln (y); + end; +  + repeat + writeln(y); + y := y + 1; + until y > 5; + writeln ('Hello World'); +end. + diff --git a/tests/syntax-tests/highlighted/Perl/test.pl b/tests/syntax-tests/highlighted/Perl/test.pl new file mode 100644 index 00000000..eda26d1d --- /dev/null +++ b/tests/syntax-tests/highlighted/Perl/test.pl @@ -0,0 +1,157 @@ +# Perl Test +# By saul-bt +# PUBLIC DOMAIN + +use strict; +use warnings; + +## REFERENCES ## +my @colors = ("red", "green", "blue"); + +# '\' can be used to get a reference +my $colorsRef = \@colors; + +my %superHash = ( + "colors" => $colorsRef, + # Also you can create an anonymous + # array with '[]' ({} for hashes) + # that returns the reference + "numbers" => [1, 2, 3] +); + +# Now the hash stores something like +# this: ("colors", ARRAY(0x...), +# "numbers", ARRAY(0x...)) + +# And you can access these arrays with: +print qq(@{$superHash{"colors"}}\n); + +# To print an element: +print qq(${$superHash{"numbers"}}[0]\n); +print $superHash{"colors"} -> [0], "\n"; + +# Size of array: +print scalar @{$superHash{"colors"}}; + + +## ARRAYS ## +%meh1 = (num => 0, val => 4); +%meh2 = ( + num => 1, + val => 3 +); + +@mehs = (\%meh1, \%meh2); + +print $mehs[0]{val}; + + +## HANDLERS & HEREDOC ## +print "What's your name? "; +$name = <STDIN>; +chomp($name); + +print <<WELCOME; + +Hi $name, Where are you from? +WELCOME + +$place = <STDIN>; +chomp($place); + +print <<GOODBYE; + +Oh, you are $name from $place... +I hear that $place is a beautiful place. +It's nice meet people like you $name. +I hope to see you soon :) + +Bye $name. +GOODBYE + +open (content, "<", "file.txt"); + +for $line (<content>) { + print $line; +} + +print "What are you looking for? "; +$numResults = 0; +$word = <STDIN>; +chomp($word); + +for $line (<>) { + if ($line =~ m/\b$word\b/i) { + $numResults += 1; + print "[$word FOUND]> $line\n"; + next; + } + print $line; +} + +print "\n\n=== There are $numResults coincidences ==="; + + +## SCRIPT ARGUMENTS ## +$nargs = $#ARGV + 1; + +print "There are $nargs arguments:\n"; + +for $arg (@ARGV) { + print "- $arg\n"; +} + +## REGEX STUFF ## +$string = "Perl is cool"; + +if ($string =~ m/[Pp]erl/) { + print "Yeah"; +} +elsif ($string =~ m(perl)i) { + print "Sad"; +} +else { + print "MEH"; +} + +# From my dummy recreation of printf +sub checkTypes { + my @percents = @{scalar(shift)}; + my @args = @{scalar(shift)}; + my $size = scalar(@percents); + + foreach my $n (0..$size - 1) { + my $currArg = $args[$n]; + my $currFormat = substr($percents[$n],-1); +  + $currFormat eq 's' && $currArg =~ m/^\D+$/ || + $currFormat =~ m/[dx]/ && $currArg =~ m/^\d+$/ || + $currFormat eq 'f' && $currArg =~ m/^\d+(?:\.\d+)?$/ or + die "'$currArg' can't be formatted as '$currFormat'"; + } +} + +## WEIRD STUFF (JAPH) ## +# VMS <3 +not exp log srand xor s qq qx xor +s x x length uc ord and print chr +ord for qw q join use sub tied qx +xor eval xor print qq q q xor int +eval lc q m cos and print chr ord +for qw y abs ne open tied hex exp +ref y m xor scalar srand print qq +q q xor int eval lc qq y sqrt cos +and print chr ord for qw x printf +each return local x y or print qq +s s and eval q s undef or oct xor +time xor ref print chr int ord lc +foreach qw y hex alarm chdir kill +exec return y s gt sin sort split + +@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{ +@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord +($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&& +close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print + +''=~('(?{'.('-)@.)@_*([]@!@/)(@)@-@),@(@@+@)' +^'][)@]`}`]()`@.@]@%[`}%[@`@!#@%[').',"})') diff --git a/tests/syntax-tests/highlighted/Plaintext/plaintext.txt b/tests/syntax-tests/highlighted/Plaintext/plaintext.txt new file mode 100644 index 00000000..1f27a79f --- /dev/null +++ b/tests/syntax-tests/highlighted/Plaintext/plaintext.txt @@ -0,0 +1,178 @@ +␀␊ +\u{1}␊ +\u{2}␊ +\u{3}␊ +\u{4}␊ +\u{5}␊ +\u{6}␊ +␇␊ +␈␊ +├──┤␊ +␊ +␊ +\u{b}␊ +\u{c}␊ +␊ +\u{e}␊ +\u{f}␊ +\u{10}␊ +\u{11}␊ +\u{12}␊ +\u{13}␊ +\u{14}␊ +\u{15}␊ +\u{16}␊ +\u{17}␊ +\u{18}␊ +\u{19}␊ +\u{1a}␊ +␛␊ +\u{1c}␊ +\u{1d}␊ +\u{1e}␊ +\u{1f}␊ +·␊ +!␊ +"␊ +#␊ +$␊ +%␊ +&␊ +'␊ +(␊ +)␊ +*␊ ++␊ +,␊ +-␊ +.␊ +/␊ +0␊ +1␊ +2␊ +3␊ +4␊ +5␊ +6␊ +7␊ +8␊ +9␊ +:␊ +;␊ +<␊ +=␊ +>␊ +?␊ +@␊ +A␊ +B␊ +C␊ +D␊ +E␊ +F␊ +G␊ +H␊ +I␊ +J␊ +K␊ +L␊ +M␊ +N␊ +O␊ +P␊ +Q␊ +R␊ +S␊ +T␊ +U␊ +V␊ +W␊ +X␊ +Y␊ +Z␊ +[␊ +\␊ +]␊ +^␊ +_␊ +`␊ +a␊ +b␊ +c␊ +d␊ +e␊ +f␊ +g␊ +h␊ +i␊ +j␊ +k␊ +l␊ +m␊ +n␊ +o␊ +p␊ +q␊ +r␊ +s␊ +t␊ +u␊ +v␊ +w␊ +x␊ +y␊ +z␊ +{␊ +|␊ +}␊ +~␊ +\u{7f}␊ +\u{80}␊ +\u{81}␊ +\u{82}␊ +\u{83}␊ +\u{84}␊ +\u{85}␊ +\u{86}␊ +\u{87}␊ +\u{88}␊ +\u{89}␊ +\u{8a}␊ +\u{8b}␊ +\u{8c}␊ +\u{8d}␊ +\u{8e}␊ +\u{8f}␊ +\u{90}␊ +\u{91}␊ +\u{92}␊ +\u{93}␊ +\u{94}␊ +\u{95}␊ +\u{96}␊ +\u{97}␊ +\u{98}␊ +\u{99}␊ +\u{9a}␊ +\u{9b}␊ +\u{9c}␊ +\u{9d}␊ +\u{9e}␊ +\u{9f}␊ +\u{a0}␊ +\u{a1}␊ +\u{a2}␊ +\u{a3}␊ +\u{a4}␊ +\u{a5}␊ +\u{a6}␊ +\u{a7}␊ +\u{a8}␊ +\u{a9}␊ +\u{aa}␊ +\u{ab}␊ +\u{ac}␊ +\u{ad}␊ +\u{ae}␊ +␊ +Here's·a·line·with·multiple·characters.␊ diff --git a/tests/syntax-tests/highlighted/PowerShell/test.ps1 b/tests/syntax-tests/highlighted/PowerShell/test.ps1 new file mode 100644 index 00000000..915b6072 --- /dev/null +++ b/tests/syntax-tests/highlighted/PowerShell/test.ps1 @@ -0,0 +1,25 @@ +# PowerShell script for testing syntax highlighting + +function Get-FutureTime { + param ( + [Int32] $Minutes + ) +  + $time = Get-Date | % { $_.AddMinutes($Minutes) } + "{0:d2}:{1:d2}:{2:d2}" -f @($time.hour, $time.minute, $time.second) +} + +if ($env:PATH -match '.*rust.*') { + 'Path contains Rust' + try { + & "cargo" "--version" + } catch { + Write-Error "Failed to run cargo" + } +} else { + 'Path does not contain Rust' +} + +(5..30) | ? { $_ % (2 * 2 + 1) -eq 0 } | % {"In {0} minutes, the time will be {1}." -f $_, $( Get-FutureTime $_ )} +$later = Get-FutureTime -Minutes $( Get-Random -Minimum 60 -Maximum 120 ) +"The time will be " + $later + " later." diff --git a/tests/syntax-tests/highlighted/PureScript/test.purs b/tests/syntax-tests/highlighted/PureScript/test.purs new file mode 100644 index 00000000..d59b29b8 --- /dev/null +++ b/tests/syntax-tests/highlighted/PureScript/test.purs @@ -0,0 +1,89 @@ +-- | This module defines a datatype `Pair` together with a few useful instances +-- | and helper functions. Note that this is not just `Tuple a a` but rather a +-- | list with exactly two elements. Specifically, the `Functor` instance maps +-- | over both values (in contrast to the `Functor` instance for `Tuple a`). +module Data.Pair + ( Pair(..) + , (~) + , fst + , snd + , curry + , uncurry + , swap + ) where + +import Prelude + +import Data.Foldable (class Foldable) +import Data.Traversable (class Traversable) +import Data.Distributive (class Distributive) + +import Test.QuickCheck.Arbitrary (class Arbitrary, arbitrary) + +-- | A pair simply consists of two values of the same type. +data Pair a = Pair a a + +infixl 6 Pair as ~ + +-- | Returns the first component of a pair. +fst ∷ ∀ a. Pair a → a +fst (x ~ _) = x + +-- | Returns the second component of a pair. +snd ∷ ∀ a. Pair a → a +snd (_ ~ y) = y + +-- | Turn a function that expects a pair into a function of two arguments. +curry ∷ ∀ a b. (Pair a → b) → a → a → b +curry f x y = f (x ~ y) + +-- | Turn a function of two arguments into a function that expects a pair. +uncurry ∷ ∀ a b. (a → a → b) → Pair a → b +uncurry f (x ~ y) = f x y + +-- | Exchange the two components of the pair +swap ∷ ∀ a. Pair a → Pair a +swap (x ~ y) = y ~ x + +derive instance eqPair ∷ Eq a ⇒ Eq (Pair a) + +derive instance ordPair ∷ Ord a ⇒ Ord (Pair a) + +instance showPair ∷ Show a ⇒ Show (Pair a) where + show (x ~ y) = "(" <> show x <> " ~ " <> show y <> ")" + +instance functorPair ∷ Functor Pair where + map f (x ~ y) = f x ~ f y + +instance applyPair ∷ Apply Pair where + apply (f ~ g) (x ~ y) = f x ~ g y + +instance applicativePair ∷ Applicative Pair where + pure x = x ~ x + +instance bindPair ∷ Bind Pair where + bind (x ~ y) f = fst (f x) ~ snd (f y) + +instance monadPair ∷ Monad Pair + +instance semigroupPair ∷ Semigroup a ⇒ Semigroup (Pair a) where + append (x1 ~ y1) (x2 ~ y2) = (x1 <> x2) ~ (y1 <> y2) + +instance monoidPair ∷ Monoid a ⇒ Monoid (Pair a) where + mempty = mempty ~ mempty + +instance foldablePair ∷ Foldable Pair where + foldr f z (Pair x y) = x `f` (y `f` z) + foldl f z (Pair x y) = (z `f` x) `f` y + foldMap f (Pair x y) = f x <> f y + +instance traversablePair ∷ Traversable Pair where + traverse f (Pair x y) = Pair <$> f x <*> f y + sequence (Pair mx my) = Pair <$> mx <*> my + +instance distributivePair ∷ Distributive Pair where + distribute xs = map fst xs ~ map snd xs + collect f xs = map (fst <<< f) xs ~ map (snd <<< f) xs + +instance arbitraryPair ∷ Arbitrary a ⇒ Arbitrary (Pair a) where + arbitrary = Pair <$> arbitrary <*> arbitrary diff --git a/tests/syntax-tests/highlighted/QML/BatSyntaxTest.qml b/tests/syntax-tests/highlighted/QML/BatSyntaxTest.qml new file mode 100644 index 00000000..1d1ada1d --- /dev/null +++ b/tests/syntax-tests/highlighted/QML/BatSyntaxTest.qml @@ -0,0 +1,219 @@ +import QtQuick 2.0 +import "../components" + +Page { + id: page + + // properties + + property bool startup: true + readonly property var var1: null + readonly property QtObject var2: null + + allowedOrientations: Orientation.All + + /* components */ + + DBusServiceWatcher { + id: dbusService + service: "org.bat.service" + + onRegisteredChanged: { + if (dbusService.registered) { + announcedNameField.text = daemon.announcedName() + } + } + } + + Component.onCompleted: { + console.debug("completed") + } + + Flickable { + anchors.fill: parent + contentHeight: column.height + visible: dbusService.registered + + ViewPlaceholder { + enabled: !startup + && trustedDevices.count == 0 + && nearDevices.count == 0 + text: qsTr("Install Bat.") + } + + Column { + id: column + + width: page.width + spacing: Theme.paddingLarge + + PageHeader { + title: qsTr("Syntax Test") + } + + TextField { + id: announcedNameField + width: parent.width + label: qsTr("Device Name") + text: dbusService.registered ? daemon.announcedName() : "" + + onActiveFocusChanged: { + if (activeFocus) + return + + if (text.length === 0) { + text = daemon.announcedName() + } else { + daemon.setAnnouncedName(text) + placeholderText = text + } + } + + EnterKey.onClicked: announcedNameField.focus = false + EnterKey.iconSource: "image://theme/icon-m-enter-close" + } + + + Component { + id: deviceDelegate + + ListItem { + id: listItem + + property bool showStatus: deviceStatusLabel.text.length + + width: page.width + height: Theme.itemSizeMedium + + Image { + id: icon + source: iconUrl + + x: Theme.horizontalPageMargin + anchors.verticalCenter: parent.verticalCenter + sourceSize.width: Theme.iconSizeMedium + sourceSize.height: Theme.iconSizeMedium + } + + Label { + id: deviceNameLabel + anchors { + left: icon.right + leftMargin: Theme.paddingLarge + right: parent.right + rightMargin: Theme.horizontalPageMargin + } + y: listItem.contentHeight / 2 - implicitHeight / 2 + - showStatus * (deviceStatusLabel.implicitHeight / 2) + + text: name + color: listItem.highlighted + ? Theme.highlightColor + : Theme.primaryColor + truncationMode: TruncationMode.Fade + textFormat: Text.PlainText + + Behavior on y { NumberAnimation {} } + } + + Label { + id: deviceStatusLabel + anchors { + left: deviceNameLabel.left + top: deviceNameLabel.bottom + right: parent.right + rightMargin: Theme.horizontalPageMargin + } + + text: (trusted && reachable) + ? qsTr("Connected") + : (hasPairingRequests || waitsForPairing + ? qsTr("Pending pairing request ...") : "") + color: listItem.highlighted + ? Theme.secondaryHighlightColor + : Theme.secondaryColor + truncationMode: TruncationMode.Fade + font.pixelSize: Theme.fontSizeExtraSmall + opacity: showStatus ? 1.0 : 0.0 + width: parent.width + textFormat: Text.PlainText + + Behavior on opacity { FadeAnimation {} } + } + + onClicked: { + pageStack.push( + Qt.resolvedUrl("DevicePage.qml"), + { deviceId: id }) + } + } + } + + DeviceListModel { + id: devicelistModel + } + + ColumnView { + id: devicesView + width: page.width + itemHeight: Theme.itemSizeMedium + + + model: trustedDevicesModel + delegate: deviceDelegate + visible: devicesView.count > 0 + } + } + + PullDownMenu { +// MenuItem { +// text: qsTr("About ...") +// onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml")) +// } + + MenuItem { + text: qsTr("Settings ...") + onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml")) + } + } + + VerticalScrollDecorator {} + } + + /* + Connections { + target: ui + onOpeningDevicePage: openDevicePage(deviceId) + }*/ + + Timer { + interval: 1000 + running: true + repeat: false + onTriggered: startup = false + } + + function openDevicePage(deviceId) { + if (typeof pageStack === "undefined") + return; + + console.log("opening device " + deviceId) + + window.activate() + + var devicePage = pageStack.find(function(page) { + return page.objectName === "DevicePage" + }) + if (devicePage !== null && devicePage.deviceId === deviceId) { + pageStack.pop(devicePage) + ui.showMainWindow() + return + } + + pageStack.pop(page, PageStackAction.Immediate) + pageStack.push( + Qt.resolvedUrl("DevicePage.qml"), + { deviceId: deviceId }, + PageStackAction.Immediate) + } +} diff --git a/tests/syntax-tests/highlighted/R/test.r b/tests/syntax-tests/highlighted/R/test.r new file mode 100644 index 00000000..2196edef --- /dev/null +++ b/tests/syntax-tests/highlighted/R/test.r @@ -0,0 +1,170 @@ +# take input from the user +num = as.integer(readline(prompt="Enter a number: ")) +factorial = 1 +# check is the number is negative, positive or zero +if(num < 0) { +print("Sorry, factorial does not exist for negative numbers") +} else if(num == 0) { +print("The factorial of 0 is 1") +} else { +for(i in 1:num) { +factorial = factorial * i +} +print(paste("The factorial of", num ,"is",factorial)) +} + +x <- 0 +if (x < 0) { +print("Negative number") +} else if (x > 0) { +print("Positive number") +} else +print("Zero") + +x <- 1:5 +for (val in x) { +if (val == 3){ +next +} +print(val) +} + +x <- 1 +repeat { +print(x) +x = x+1 +if (x == 6){ +break +} +} + +`%divisible%` <- function(x,y) +{ +if (x%%y ==0) return (TRUE) +else return (FALSE) +} + +switch("length", "color" = "red", "shape" = "square", "length" = 5) +[1] 5 + +recursive.factorial <- function(x) { +if (x == 0) return (1) +else return (x * recursive.factorial(x-1)) +} + +pow <- function(x, y) { +# function to print x raised to the power y +result <- x^y +print(paste(x,"raised to the power", y, "is", result)) +} + +A <- read.table("x.data", sep=",", + col.names=c("year", "my1", "my2")) +nrow(A) # Count the rows in A + +summary(A$year)  + +A$newcol <- A$my1 + A$my2 # Makes a new +newvar <- A$my1 - A$my2 # Makes a  +A$my1 <- NULL # Removes  +str(A) +summary(A) +library(Hmisc)  +contents(A) +describe(A) + +set.seed(102) # This yields a good illustration. +x <- sample(1:3, 15, replace=TRUE) +education <- factor(x, labels=c("None", "School", "College")) +x <- sample(1:2, 15, replace=TRUE) +gender <- factor(x, labels=c("Male", "Female")) +age <- runif(15, min=20,max=60) + +D <- data.frame(age, gender, education) +rm(x,age,gender,education) +print(D) + +# Table about education +table(D$education) + +# Table about education and gender -- +table(D$gender, D$education) +# Joint distribution of education and gender -- +table(D$gender, D$education)/nrow(D) + +# Add in the marginal distributions also +addmargins(table(D$gender, D$education)) +addmargins(table(D$gender, D$education))/nrow(D) + +# Generate a good LaTeX table out of it -- +library(xtable) +xtable(addmargins(table(D$gender, D$education))/nrow(D), + digits=c(0,2,2,2,2))  + +by(D$age, D$gender, mean) +by(D$age, D$gender, sd) +by(D$age, D$gender, summary) + +a <- matrix(by(D$age, list(D$gender, D$education), mean), nrow=2) +rownames(a) <- levels(D$gender) +colnames(a) <- levels(D$education) +print(a) +print(xtable(a)) + +dat <- read.csv(file = "files/dataset-2013-01.csv", header = TRUE) +interim_object <- data.frame(rep(1:100, 10), + rep(101:200, 10), + rep(201:300, 10)) +object.size(interim_object)  +rm("interim_object")  +ls()  +rm(list = ls()) + +vector1 <- c(5,9,3) +vector2 <- c(10,11,12,13,14,15) +array1 <- array(c(vector1,vector2),dim = c(3,3,2)) +vector3 <- c(9,1,0) +vector4 <- c(6,0,11,3,14,1,2,6,9) +array2 <- array(c(vector1,vector2),dim = c(3,3,2)) +matrix1 <- array1[,,2] +matrix2 <- array2[,,2] +result <- matrix1+matrix2 +print(result) + +column.names <- c("COL1","COL2","COL3") +row.names <- c("ROW1","ROW2","ROW3") +matrix.names <- c("Matrix1","Matrix2") +result <- array(c(vector1,vector2),dim = c(3,3,2),dimnames = list(row.names, + column.names, matrix.names)) +print(result[3,,2]) +print(result[1,3,1]) +print(result[,,2]) + +# Load the package required to read JSON files. +library("rjson") +result <- fromJSON(file = "input.json") +print(result) + +x <- c(151, 174, 138, 186, 128, 136, 179, 163, 152, 131) +y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48) +relation <- lm(y~x) +print(relation) + +relation <- lm(y~x) +png(file = "linearregression.png") +plot(y,x,col = "blue",main = "Height & Weight Regression", +abline(lm(x~y)),cex = 1.3,pch = 16,xlab = "Weight in Kg",ylab = "Height in cm") +dev.off() + +data <- c("East","West","East","North","North","East","West","West","West","East","North") +print(data) +print(is.factor(data)) +factor_data <- factor(data) +print(factor_data) +print(is.factor(factor_data)) + +v <- c(7,12,28,3,41) + +# Give the chart file a name. +png(file = "line_chart_label_colored.jpg") +plot(v,type = "o", col = "red", xlab = "Month", ylab = "Rain fall", main = "Rain fall chart") diff --git a/tests/syntax-tests/highlighted/Regular Expression/test.re b/tests/syntax-tests/highlighted/Regular Expression/test.re new file mode 100644 index 00000000..912b568b --- /dev/null +++ b/tests/syntax-tests/highlighted/Regular Expression/test.re @@ -0,0 +1 @@ +^\[START\]\d\D\h\H\s\S[a-z]\v\V\w\W.([a-z]){3,5}\[END\]$ diff --git a/tests/syntax-tests/highlighted/RequirementsTXT/requirements.txt b/tests/syntax-tests/highlighted/RequirementsTXT/requirements.txt new file mode 100644 index 00000000..b7c5155f --- /dev/null +++ b/tests/syntax-tests/highlighted/RequirementsTXT/requirements.txt @@ -0,0 +1,8 @@ +#this is a sample requirements.txt file + +django==11.2.0 +pywheels>=12.4 #a whitespace followed by comments +Nuitka<0.6.8.4 +wxPython>=1.0, <=2.1 + +#this is another comment diff --git a/tests/syntax-tests/highlighted/Ruby Haml/test.html.haml b/tests/syntax-tests/highlighted/Ruby Haml/test.html.haml new file mode 100644 index 00000000..06a46d43 --- /dev/null +++ b/tests/syntax-tests/highlighted/Ruby Haml/test.html.haml @@ -0,0 +1,15 @@ +%html + %head + %title Test Title + %body + %navigation + = render :partial => "navigation_top" + %h1= page.title + %p + Here is a point to emphasize: + %strong.highlighted#search_item_found= item1.text + %span{:class => "fancy", :id => "fancy1"}= item2.text + .special= special.text + %ol + %li First + %li Second diff --git a/tests/syntax-tests/highlighted/Ruby On Rails/test.rb b/tests/syntax-tests/highlighted/Ruby On Rails/test.rb new file mode 100644 index 00000000..9b2a9b66 --- /dev/null +++ b/tests/syntax-tests/highlighted/Ruby On Rails/test.rb @@ -0,0 +1,22 @@ +class ContactsController < ApplicationController + def new + @contact = Contact.new + end + + def create + @contact = Contact.new(secure_params) + if @contact.valid? + UserMailer.contact_email(@contact).deliver_now + flash[:notice] = "Message sent from #{@contact.name}." + redirect_to root_path + else + render :new + end + end + + private + + def secure_params + params.require(:contact).permit(:name, :email, :content) + end +end diff --git a/tests/syntax-tests/highlighted/SASS/example.sass b/tests/syntax-tests/highlighted/SASS/example.sass deleted file mode 100644 index ed78c867..00000000 --- a/tests/syntax-tests/highlighted/SASS/example.sass +++ /dev/null @@ -1,19 +0,0 @@ -@mixin button-base() { - @include typography(button); - @include ripple-surface; - @include ripple-radius-bounded; - - display: inline-flex; - position: relative; - height: $button-height; - border: none; - vertical-align: middle; - - &:hover { cursor: pointer; } - - &:disabled { - color: $mdc-button-disabled-ink-color; - cursor: default; - pointer-events: none; - } -} diff --git a/tests/syntax-tests/highlighted/SCSS/example.scss b/tests/syntax-tests/highlighted/SCSS/example.scss new file mode 100644 index 00000000..7ba949d8 --- /dev/null +++ b/tests/syntax-tests/highlighted/SCSS/example.scss @@ -0,0 +1,82 @@ +@import 'fonts'; + +$theme_dark: ( + "background-color": null, +); +$theme_main: ( + "text-size": 3em, + "text-color": black, + "text-shadow": #36ad 0px 0px 3px, + "card-background": #d6f, + "card-shadow": #11121212 0px 0px 2px 1px, + "card-padding": 1rem, + "card-margin": 0.5in, + "image-width": 600px, + "image-height": 100vh, + "background-color": #dedbef, + "i-ran-out-of-placeholders-for-units": (1vw 100% 60pt), +); + +$current_theme: $theme_main; + +@mixin themed() { + $current_theme: $theme_main !global; + @content; + + @media (prefers-color-scheme: dark) { + $current_theme: $theme_dark !global; + @content; + } +  + .#{"dark"} & { + $current_theme: $theme_dark !global; + @content; + } +} + +@function theme($variable) { + @if map-has_key($current_theme, $variable) { + @return map-get($current_theme, $variable); + } @else { + @error "Unknown theme variable: #{$variable}"; + } +} + +body { + @include themed { + background-color: theme('background-color'); + background-image: url("https://github.com/sharkdp/bat/raw/master/doc/logo-header.svg"); + } +  + header[data-selectable="false"] { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: /* CSS comment */ none; + cursor: default !important; // SCSS comment + } +  + > div { + border: #04f 1px solid; +  + &::after { + content: 'Pseudo'; + color: #2F5F7F; + box-sizing: border-box; + } + } +} + +@keyframes rotate { + 0% { + transform: rotate(0deg); + } + 50% { + transform: rotate(180deg)} + 100% {transform: rotate(0rad);} +} + +@font-face { + font-family: 'Example Font'; + src: url(example.ttf) format('ttf'); + src: local('Comic Sans MS'); +} diff --git a/tests/syntax-tests/highlighted/SLS/test.sls b/tests/syntax-tests/highlighted/SLS/test.sls new file mode 100644 index 00000000..3e4c6386 --- /dev/null +++ b/tests/syntax-tests/highlighted/SLS/test.sls @@ -0,0 +1,57 @@ +required_packages: + pkg.installed: + - pkgs: + - git + - perl + - fortune + +cowsay_source: + git.latest: + - name: https://github.com/jasonm23/cowsay.git + - target: /root/cowsay + +run_installer: + cmd.run: + - name: ./install.sh /usr/local + - cwd: /root/cowsay + - onchanges: + - git: cowsay_source + +{% set cowfiles = salt.cmd.run('cowsay -l').split('\n')[1:] %} +{% set ascii_arts = cowfiles | join(' ') %} + +{% for ascii_art in ascii_arts.split(' ') %} +run_cowsay_{{ ascii_art }}: # name must be unique + cmd.run: + {% if ascii_art is in ['head-in', 'sodomized', 'telebears'] %} + - name: echo cowsay -f {{ ascii_art }} should not be used + {% else %} + - name: fortune | cowsay -f {{ ascii_art }} + {% endif %} +{% endfor %} + +echo_pillar_demo_1: + cmd.run: + - name: "echo {{ pillar.demo_text | default('pillar not defined') }}" + +echo_pillar_demo_2: + cmd.run: + - name: "echo {{ pillar.demo.text | default('pillar not defined') }}" + +# Comment +{% set rand = salt['random.get_str'](20) %} +{% set IP_Address = pillar['IP_Address'] %} + +wait: + cmd.run: + - name: sleep 210 # another comment + +create_roster_file: + file.managed: + - name: /tmp/salt-roster-{{ rand }} + - contents: + - 'switch:' + - ' host: {{ IP_Address }}' + - " user: test" + - " passwd: {{ passwd }}" + diff --git a/tests/syntax-tests/highlighted/SSHD Config/sshd_config b/tests/syntax-tests/highlighted/SSHD Config/sshd_config new file mode 100644 index 00000000..d54bfc1c --- /dev/null +++ b/tests/syntax-tests/highlighted/SSHD Config/sshd_config @@ -0,0 +1,36 @@ +# This test sshd config file is intended for syntax testing +# purposes only. +# +# Definitely do not use this in production for sshd. + +Port 22 + +# Here's a directive commented out: +#ListenAddress 0.0.0.0 + +ListenAddress 127.0.0.1 + +HostKey /etc/ssh/ssh_host_rsa_key +IgnoreRhosts yes +PrintMotd yes +X11Forwarding no +AllowAgentForwarding no +PermitRootLogin forced-commands-only +SyslogFacility AUTH + +LogLevel VERBOSE + +AuthorizedKeysFile /etc/ssh/authorized-keys/%u + +PasswordAuthentication yes +PermitEmptyPasswords no +AllowUsers alice + +# pass locale information +AcceptEnv LANG LC_* + +Banner /etc/sshd_banner + +AllowTcpForwarding yes +PermitTunnel no +PermitTTY yes diff --git a/tests/syntax-tests/highlighted/Sass/example.sass b/tests/syntax-tests/highlighted/Sass/example.sass new file mode 100644 index 00000000..845a2b94 --- /dev/null +++ b/tests/syntax-tests/highlighted/Sass/example.sass @@ -0,0 +1,76 @@ +@import "fonts" + +$theme_dark: ( + "background-color": null +) + +$theme_main: ( + "text-size": 3em + "text-color": black + "text-shadow": #36ad 0px 0px 3px + "card-background": #d6f + "card-shadow": #11121212 0px 0px 2px 1px + "card-padding": 1rem + "card-margin": 0.5in + "image-width": 600px + "image-height": 100vh + "background-color": #dedbef + "i-ran-out-of-placeholders-for-units": ( + 1vw 100% 60pt + ) +) + +$current_theme: $theme_main + +@mixin themed() + $current_theme: $theme_main !global + @content + + @media (prefers-color-scheme: dark) + $current_theme: $theme_dark !global + @content + + .#{"dark"} & + $current_theme: $theme_dark !global + @content + +@function theme($variable) + @if map-has_key($current_theme, $variable) + @return map-get($current_theme, $variable) + @else + @error "Unknown theme variable: #{$variable}" + +body + @include themed + background-color: theme("background-color") + background-image: url("https://github.com/sharkdp/bat/raw/master/doc/logo-header.svg") + + + header[data-selectable="false"] + -webkit-user-select: none + -moz-user-select: none + -ms-user-select: /* CSS comment */ none + cursor: default !important // Sass comment + + + > div + border: #04f 1px solid + + &::after + content: "Pseudo" + color: #2f5f7f + box-sizing: border-box + +@keyframes rotate + 0% + transform: rotate(0deg) + 50% + transform: rotate(180deg) + 100% + transform: rotate(0rad) + +@font-face + font-family: "Example Font" + src: url(example.ttf) format("ttf") + src: local("Comic Sans MS") + diff --git a/tests/syntax-tests/highlighted/Svelte/App.svelte b/tests/syntax-tests/highlighted/Svelte/App.svelte new file mode 100644 index 00000000..aff961d5 --- /dev/null +++ b/tests/syntax-tests/highlighted/Svelte/App.svelte @@ -0,0 +1,57 @@ +<script> + import { onMount } from 'svelte'; + import List from './List.svelte'; + import Item from './Item.svelte'; + + let item; + let page; + + async function hashchange() { + // the poor man's router! + const path = window.location.hash.slice(1); + + if (path.startsWith('/item')) { + const id = path.slice(6); + item = await fetch(`https://node-hnapi.herokuapp.com/item/${id}`).then(r => r.json()); + + window.scrollTo(0,0); + } else if (path.startsWith('/top')) { + page = +path.slice(5); + item = null; + } else { + window.location.hash = '/top/1'; + } + } + + onMount(hashchange); + + +<style> + main { + position: relative; + max-width: 800px; + margin: 0 auto; + min-height: 101vh; + padding: 1em; + } + + main :global(.meta) { + color: #999; + font-size: 12px; + margin: 0 0 1em 0; + } + + main :global(a) { + color: rgb(0,0,150); + } + + +<svelte:window on:hashchange={hashchange}/> + +<main> + {#if item} + <Item {item} returnTo="#/top/{page}"/> + {:else if page} + <List {page}/> + {/if} + diff --git a/tests/syntax-tests/highlighted/Swift/test.swift b/tests/syntax-tests/highlighted/Swift/test.swift new file mode 100644 index 00000000..e31eb16a --- /dev/null +++ b/tests/syntax-tests/highlighted/Swift/test.swift @@ -0,0 +1,268 @@ +class Person { +// We can define class property here +var age = 25 +// Implement Class initializer. Initializers are called when a new object of this class is created +init() {  + print(“A new instance of this class Person is created.”)  + }  +}  +// We can now create an instance of class Person - an object - by putting parentheses after the class name +let personObj = Person() +// Once an instance of Person class is created we can access its properties using the dot “.” syntax. +print(“This person age is \(personObj.age)”) + +import Foundation +class Friend : Comparable { + let name : String + let age : Int +  + init(name : String, age: Int) { + self.name = name + self.age = age + } +} +func < (lhs: Friend, rhs: Friend) -> Bool { + return lhs.age < rhs.age }; func > (lhs: Friend, rhs: Friend) -> Bool { + return lhs.age > rhs.age +} +func == (lhs: Friend, rhs: Friend) -> Bool { + var returnValue = false + if (lhs.name == rhs.name) && (lhs.age == rhs.age) + { + returnValue = true + } + return returnValue +} + + let friend1 = Friend(name: "Sergey", age: 35) + let friend2 = Friend(name: "Sergey", age: 30) +  + print("Compare Friend object. Same person? (friend1 == friend2)") + +func sayHelloWorld() { + print("Hello World") +} +// Call function +sayHelloWorld() + +func printOutFriendNames(names: String...) { +  + for name in names { +  + print(name) + } +  +} +// Call the printOutFriendNames with two parameters +printOutFriendNames("Sergey", "Bill") +// Call the function with more parameters +printOutFriendNames("Sergey", "Bill", "Max") + +let simpleClosure = { + print("From a simpleClosure") +} +// Call closure +simpleClosure()  + +let fullName = { (firstName:String, lastName:String)->String in + return firstName + " " + lastName +} +// Call Closure +let myFullName = fullName("Sergey", "Kargopolov") +print("My full name is \(myFullName)") + +let myDictionary = [String:String]() +// Another way to create an empty dictionary +let myDictionary2:[String:String] = [:] +// Keys in dictionary can also be of type Int +let myDictionary3 = [Int:String]() + +var myDictionary = ["first_name": "Sergey", "last_name": "Kargopolov"] +// print to preview +print(myDictionary) +// Add a new key with a value +myDictionary["user_id"] = "f5h7ru0tJurY8f7g5s6fd" +// We should now have 3 key value pairs printed +print(myDictionary) + +var myDictionary = ["first_name": "Sergey", "last_name": "Kargopolov"] +// Loop through dictionary keys and print values +for (key,value) in myDictionary { + print("\(key) = \(value)") +} + class Friend { + let name : String + let age : Int +  + init(name : String, age: Int) { + self.name = name + self.age = age + } +} + + var friends:[Friend] = [] +  + let friend1 = Friend(name: "Sergey", age: 30) + let friend2 = Friend(name: "Bill", age: 35) + let friend3 = Friend(name: "Michael", age: 21) +  + friends.append(friend1) + friends.append(friend2) + friends.append(friend3) +  + printFriends(friends: friends) +  + // Get sorted array in descending order (largest to the smallest number) + let sortedFriends = friends.sorted(by: { $0.age > $1.age }) + printFriends(friends: sortedFriends) +  + // Get sorted array in ascending order (smallest to the largest number) + let sortedFriendsAscendingOrder = friends.sorted(by: { $0.age < $1.age }) + printFriends(friends: sortedFriendsAscendingOrder) + + + func printFriends(friends: [Friend]) + { + for friendEntry in friends { + print("Name: \(friendEntry.name), age: \(friendEntry.age)") + } + } + +import UIKit +class ViewController: UIViewController { +override func viewDidLoad() { + super.viewDidLoad() +} +override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) +  + // Create destination URL  + let documentsUrl:URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first as URL! + let destinationFileUrl = documentsUrl.appendingPathComponent("downloadedFile.jpg") +  + //Create URL to the source file you want to download + let fileURL = URL(string: "https://s3.amazonaws.com/learn-swift/IMG_0001.JPG") +  + let sessionConfig = URLSessionConfiguration.default + let session = URLSession(configuration: sessionConfig) +  + let request = URLRequest(url:fileURL!) +  + let task = session.downloadTask(with: request) { (tempLocalUrl, response, error) in + if let tempLocalUrl = tempLocalUrl, error == nil { + // Success + if let statusCode = (response as? HTTPURLResponse)?.statusCode { + print("Successfully downloaded. Status code: \(statusCode)") + } +  + do { + try FileManager.default.copyItem(at: tempLocalUrl, to: destinationFileUrl) + } catch (let writeError) { + print("Error creating a file \(destinationFileUrl) : \(writeError)") + } +  + } else { + print("Error took place while downloading a file. Error description: %@", error?.localizedDescription); + } + } + task.resume() +  + } +} + + do { +  + // Convert JSON Object received from server side into Swift NSArray. + // Note the use "try" + if let convertedJsonIntoArray = try JSONSerialization.JSONObjectWithData(data!, options: []) as? NSArray { + } +  + } catch let error as NSError { + print(error.localizedDescription) + } + +DispatchQueue.global(qos: .userInitiated).async { + // Do some time consuming task in this background thread + // Mobile app will remain to be responsive to user actions +  + print("Performing time consuming task in this background thread") +  + DispatchQueue.main.async { + // Task consuming task has completed + // Update UI from this block of code + print("Time consuming task has completed. From here we are allowed to update user interface.") + } + } + +import UIKit +class ViewController: UIViewController { +  + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. +  + let button = UIButton(type: UIButtonType.system) as UIButton +  + let xPostion:CGFloat = 50 + let yPostion:CGFloat = 100 + let buttonWidth:CGFloat = 150 + let buttonHeight:CGFloat = 45 +  + button.frame = CGRect(x:xPostion, y:yPostion, width:buttonWidth, height:buttonHeight) +  + button.backgroundColor = UIColor.lightGray + button.setTitle("Tap me", for: UIControlState.normal) + button.tintColor = UIColor.black + button.addTarget(self, action: #selector(ViewController.buttonAction(_:)), for: .touchUpInside) +  + self.view.addSubview(button) + } +  + func buttonAction(_ sender:UIButton!) + { + print("Button tapped") + } +  + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } +  +  +} + +import UIKit +class ViewController: UIViewController { +  + override func viewDidLoad() { + super.viewDidLoad() +  + //Create Activity Indicator + let myActivityIndicator = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.gray) +  + // Position Activity Indicator in the center of the main view + myActivityIndicator.center = view.center +  + // If needed, you can prevent Acivity Indicator from hiding when stopAnimating() is called + myActivityIndicator.hidesWhenStopped = false +  + // Start Activity Indicator + myActivityIndicator.startAnimating() +  + // Call stopAnimating() when need to stop activity indicator + //myActivityIndicator.stopAnimating() +  +  + view.addSubview(myActivityIndicator) + } +  + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + } +  +} + + + + + diff --git a/tests/syntax-tests/highlighted/Tcl/test.tcl b/tests/syntax-tests/highlighted/Tcl/test.tcl new file mode 100644 index 00000000..8c87e2c7 --- /dev/null +++ b/tests/syntax-tests/highlighted/Tcl/test.tcl @@ -0,0 +1,22 @@ +set part1 hello +set part2 how; set part3 are +set part4 you + +set part2; + +set greeting $part1$part2$part3$part4 + +set somevar { + This is a literal $ sign, and this \} escaped + brace remains uninterpreted +} + +set name Neo +set greeting "Hello, $name" + +variable name NotNeo + +namespace eval people { + set name NeoAgain +} + diff --git a/tests/syntax-tests/highlighted/Terraform/main.tf b/tests/syntax-tests/highlighted/Terraform/main.tf new file mode 100644 index 00000000..80fb6a92 --- /dev/null +++ b/tests/syntax-tests/highlighted/Terraform/main.tf @@ -0,0 +1,48 @@ +provider "github" { + organization = var.github_organization +} + +resource "tls_private_key" "deploy_key" { + algorithm = "RSA" + rsa_bits = "4096" +} + +resource "null_resource" "private_key_file" { + triggers = { + deploy_key = tls_private_key.deploy_key.private_key_pem + } + + provisioner "file" { + content = tls_private_key.deploy_key.private_key_pem + destination = "~/${var.repo_name}_deploy_key.pem" + + connection { + type = "ssh" + user = "centos" + private_key = var.terraform_ssh_key + host = var.server_ip + } + } + + provisioner "remote-exec" { + inline = [ + "sudo mv ~/${var.repo_name}_deploy_key.pem /app/ssh_keys/", + "sudo chmod 0400 /app/ssh_keys/${var.repo_name}_deploy_key.pem", + "sudo chown app:app /app/ssh_keys/${var.repo_name}_deploy_key.pem", + ] + + connection { + type = "ssh" + user = "centos" + private_key = var.terraform_ssh_key + host = var.server_ip + } + } +} + +resource "github_repository_deploy_key" "repo_deploy_key" { + title = "${var.env_name} Deploy Key" + repository = var.repo_name + key = tls_private_key.deploy_key.public_key_openssh + read_only = var.read_only +} diff --git a/tests/syntax-tests/highlighted/Textile/test.textile b/tests/syntax-tests/highlighted/Textile/test.textile new file mode 100644 index 00000000..f0b7a71d --- /dev/null +++ b/tests/syntax-tests/highlighted/Textile/test.textile @@ -0,0 +1,40 @@ +###. Single line comment + +###.. +Multi line comment. + +This line is also part of comment. + +Continues till next block element + +p. This is not a comment, but I am a paragraph. + + + + +h1. This is an <h1> + +h2. This is an <h2> + +h3. This is an <h3> + +h4. This is an <h4> + +h5. This is an <h5> + +h6. This is an <h6> + +-- + +* Item +** Sub-Item +* Another item +** Another sub-item +** Yet another sub-item +*** Three levels deep + +p{color:red}. This line will be red. + +%span% are enclosed in percent symbols. + +div. This is a new div element diff --git a/tests/syntax-tests/highlighted/VimL/source.vim b/tests/syntax-tests/highlighted/VimL/source.vim new file mode 100644 index 00000000..77a5638c --- /dev/null +++ b/tests/syntax-tests/highlighted/VimL/source.vim @@ -0,0 +1,92 @@ +if &compatible + set nocompatible +endif + +if has('win32') || has ('win64') + let $VIMHOME = $HOME . "/vimfiles" +elseif v:false && v:true + echo "Can't get here" +else + let $VIMHOME = $HOME . "/.vim" +endif + +" show existing tab with 2 spaces width +set tabstop=2 +" when indenting with '>', use 2 spaces width +set shiftwidth=2 +" always set autoindenting on +set autoindent + +autocmd VimEnter * echo "Hello Vim" + +" Allow :W and :Wq to save too +command! Wq :wq +command! W :w + +augroup vimrc + autocmd! + autocmd FileType * echo "New filetype" +augroup END + +function! s:echo(what) + return a:what +endfunction + +function! HelloWorld(name) + let l:function_local = "function_local_var" + let l:parts = split(l:function_local, "_") + let l:greeting = "Hello " . a:name + return s:echo(l:greeting) +endfunction + +function! source#Hello() + return "Hello from namespace" +endfunction + +function! EchoFunc(...) + for s in a:000 + echon ' ' . s + endfor +endfunction + +imap  =HelloWorld("World") + +command! -nargs=? Echo :call EchoFunc() + +" TODO test stuff +let g:global = "global var" +let s:script_var = "script var" +let w:window_var = "window war" +let b:buffer_var = "buffer war" +let t:tab_var = "tab war" +echo v:false + +3 + 5 + +echo "Hello" ==# "Hello2" +echo "Hello" ==? "Hello2" +echo "Hello" == "Hello2" +echo "Hello" is "Hello2" +echo "Hello" isnot "Hello2" +echo "Hello" =~ 'xx*' +echo "Hello" !~ "Hello2" +echo "Hello" !~ "Hello2" + +echo "/This/should/not/be/a/regex" + +" Error case from issue #1604 (https://github.com/sharkdp/bat/issues/1064) +set runtimepath=~/foo/bar + +silent g/Aap/p + +let g:dict = {} +let g:dict.item = ['l1', 'l2'] + +let g:dict2 = {'dict_item': ['l1', 'l2'], 'di2': 'x'} + +silent g/regex/ +silent v/regex/ +silent %s/regex/not_regex/ + +filetype plugin indent on +syntax enable diff --git a/tests/syntax-tests/highlighted/Vue/example.vue b/tests/syntax-tests/highlighted/Vue/example.vue new file mode 100644 index 00000000..d8da0852 --- /dev/null +++ b/tests/syntax-tests/highlighted/Vue/example.vue @@ -0,0 +1,55 @@ +<template> + <div id="app" class="container-fluid"> + <AppHeader> + <transition name="page" mode="out-in" v-if="!isLoading"> + <router-view> +  + <AppLoadingIndicator> +  + + +<script> +import AppHeader from "@/components/AppHeader"; +import AppLoadingIndicator from "@/components/AppLoadingIndicator"; +import { mapGetters } from "vuex"; + +export default { + name: "App", + components: { + AppHeader, + AppLoadingIndicator, + }, + beforeCreate() { + this.$store.dispatch("fetchData"); + }, + data: { + message: "Hello!" + }, + computed: { + ...mapGetters({ + isLoading: "isLoading", + }), + }, +}; + + +<style> +body { + background-color: rgba(72, 163, 184, 0.05) !important; +} + +.page-enter-active, +.page-leave-active { + transition: opacity 0.2s; +} + +.page-enter, +.page-leave-active { + opacity: 0; +} + +.page-enter:hover { + opacity: 1; +} + + diff --git a/tests/syntax-tests/highlighted/YAML/example.yaml b/tests/syntax-tests/highlighted/YAML/example.yaml index a6e2c00c..23e50275 100644 --- a/tests/syntax-tests/highlighted/YAML/example.yaml +++ b/tests/syntax-tests/highlighted/YAML/example.yaml @@ -4,6 +4,9 @@ name: Test User username: "testuser" other_names: ['Bob', 'Bill', 'George'] +hexa: 0x11c3 #inline comment +octa: 021131 +lastseen: .NAN enabled: true locked: false groups:  @@ -13,6 +16,19 @@ address: >  123 Alphabet Way  San Francisco, CA +bio: | + I am a hardworking person + and a member of the + executive staff phone: null +email: ~ building_access: yes secure_access: no +bulb: On +fans: Off +emails: + executives: + - bob@example.com + - bill@example.com + supervisors: + - george@example.com diff --git a/tests/syntax-tests/highlighted/Zig/example.zig b/tests/syntax-tests/highlighted/Zig/example.zig new file mode 100644 index 00000000..7153dbfc --- /dev/null +++ b/tests/syntax-tests/highlighted/Zig/example.zig @@ -0,0 +1,107 @@ +//! this is a top level doc, starts with "//!" + +const std = @import("std"); + +pub fn main() anyerror!void { + const stdout = std.io.getStdOut().writer(); + try stdout.print("Hello, {}!\n", .{"world"}); +} + +const expect = std.testing.expect; + +test "comments" { + // comments start with "//" until newline + // foo bar baz + const x = true; // another comment + expect(x); +} + +/// a doc comment starts with "///" +/// multiple lines are merged together +const Timestamp = struct { + /// number of seconds since epoch + seconds: i64, + + /// number of nanoseconds past the second + nano: u32, + + const Self = @This(); + + pub fn unixEpoch() Self { + return Self{ + .seconds = 0, + .nanos = 0, + }; + } +}; + +const my_val = switch (std.Target.current.os.tag) { + .linux => "Linux", + else => "not Linux", +}; + +const Book = enum { + paperback, + hardcover, + ebook, + pdf, +}; + +const TokenType = union(enum) { + int: isize, + float: f64, + string: []const u8, +}; + +const array_lit: [4]u8 = .{ 11, 22, 33, 44 }; +const sentinal_lit = [_:0]u8{ 1, 2, 3, 4 }; + +test "address of syntax" { + // Get the address of a variable: + const x: i32 = 1234; + const x_ptr = &x; + + // Dereference a pointer: + expect(x_ptr.* == 1234); + + // When you get the address of a const variable, you get a const pointer to a single item. + expect(@TypeOf(x_ptr) == *const i32); + + // If you want to mutate the value, you'd need an address of a mutable variable: + var y: i32 = 5678; + const y_ptr = &y; + expect(@TypeOf(y_ptr) == *i32); + y_ptr.* += 1; + expect(y_ptr.* == 5679); +} + +// integer literals +const decimal_int = 98222; +const hex_int = 0xff; +const another_hex_int = 0xFF; +const octal_int = 0o755; +const binary_int = 0b11110000; + +// underscores may be placed between two digits as a visual separator +const one_billion = 1_000_000_000; +const binary_mask = 0b1_1111_1111; +const permissions = 0o7_5_5; +const big_address = 0xFF80_0000_0000_0000; + +// float literals +const floating_point = 123.0E+77; +const another_float = 123.0; +const yet_another = 123.0e+77; + +const hex_floating_point = 0x103.70p-5; +const another_hex_float = 0x103.70; +const yet_another_hex_float = 0x103.70P-5; + +// underscores may be placed between two digits as a visual separator +const lightspeed = 299_792_458.000_000; +const nanosecond = 0.000_000_001; +const more_hex = 0x1234_5678.9ABC_CDEFp-10; + +fn max(comptime T: type, a: T, b: T) T { + return if (a > b) a else b; +} diff --git a/tests/syntax-tests/highlighted/nginx/nginx.conf b/tests/syntax-tests/highlighted/nginx/nginx.conf new file mode 100644 index 00000000..4b2f9da9 --- /dev/null +++ b/tests/syntax-tests/highlighted/nginx/nginx.conf @@ -0,0 +1,140 @@ +#user nobody; +worker_processes 1; +#pid logs/nginx.pid; + +load_module "/usr/local/libexec/nginx/ngx_http_xslt_filter_module.so"; +load_module "/usr/local/libexec/nginx/ngx_rtmp_module.so"; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile  on; + keepalive_timeout 65; + gzip  on; + gzip_disable "msie6"; + + include /usr/local/etc/nginx/sites.d/*; +} + +rtmp { + server { + listen 1935; + max_message 10M; + + application wnob { + live on; + record off; + } + + application strim { + live on; + hls on; + + hls_path /usr/local/www/hls/; + + hls_variant _low BANDWIDTH=250000; + hls_variant _mid BANDWIDTH=500000; + hls_variant _high BANDWIDTH=1000000; + hls_variant _hd720 BANDWIDTH=1500000; + hls_variant _src BANDWIDTH=2000000; + } + } +} + +server { + listen 443 ssl; + server_name host.example.com + root /usr/local/www/host.example.com/; + error_page 404 /404.html; + + index index.html; + autoindex on; + autoindex_localtime off; + autoindex_format xml; + + location / { + xslt_stylesheet /usr/local/www/host.example.com/index.xslt; + } + + location ~ /\..* { + return 404; + } + + location ~ /.+/ { + xslt_stylesheet /usr/local/www/host.example.com/project.xslt; + } + + location ~ /.*\.xslt/ { + return 404; + } + + location ~ \.thumb\.png$ { + error_page 404 /404.thumb.png; + } + ssl_certificate /usr/local/etc/letsencrypt/live/host.example.com/fullchain.pem; # managed by Certbot + ssl_certificate_key /usr/local/etc/letsencrypt/live/host.example.com/privkey.pem; # managed by Certbot + + include /usr/local/etc/letsencrypt/options-ssl-nginx.conf; + ssl_dhparam /usr/local/etc/letsencrypt/ssl-dhparams.pem; + + add_header Strict-Transport-Security "max-age=31536000" always; + +} + +server { + listen 80; + server_name host.example.com; + + if ($host = host.example.com) { + return 301 https://$host$request_uri; + } + + return 404; +} + +server { + listen 443 ssl; + server_name other.example.com; + + ssl_certificate /usr/local/etc/letsencrypt/live/other.example.com/fullchain.pem; + ssl_certificate_key /usr/local/etc/letsencrypt/live/other.example.com/privkey.pem; + + include /usr/local/etc/letsencrypt/options-ssl-nginx.conf; + ssl_dhparam /usr/local/etc/letsencrypt/ssl-dhparams.pem; + + add_header Strict-Transport-Security "max-age=31536000" always; + + access_log /home/otherapp/logs/access.log; + error_log /home/otherapp/logs/error.log; + + client_max_body_size 5M; + + location / { + root /home/otherapp/app/static; + index man.txt; + try_files $uri @proxy; + } + + location @proxy { + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_pass http://unix:/var/run/otherapp/sock:; + } +} + +server { + listen 80; + server_name other.example.com; + + if ($host = other.example.com) { + return 301 https://$host$request_uri; + } + + return 404; +} diff --git a/tests/syntax-tests/highlighted/nim/main.nim b/tests/syntax-tests/highlighted/nim/main.nim new file mode 100644 index 00000000..044c2590 --- /dev/null +++ b/tests/syntax-tests/highlighted/nim/main.nim @@ -0,0 +1,41 @@ +import json + +const + message = "hello world" + multiLine = """ + foo + bar + """ + numbers = @[1, 2, 3] + +type Options = enum + A, + B, + C + +## Top-level comment +type + SomeStruct* = ref object + value*: string + +proc someFunc*(): string = + ## Function docs + ## + ## More docs + result = message + +proc someOtherFunc(startingValue: int): (string, int) = + var num = startingValue + num += 1 + if num > 10 * 10 * 10: + echo "Encountered an error" + raise newException(ValueError, "Value was over 1000") + ("Fizz", num) + +proc `+=`(a: var SomeStruct, b: SomeStruct): string = + a.value.add(b.value) + return a.value + +echo someFunc() +echo(someOtherFunc(123)) +discard someFunc() diff --git a/tests/syntax-tests/highlighted/nix/test.nix b/tests/syntax-tests/highlighted/nix/test.nix new file mode 100644 index 00000000..bf86676a --- /dev/null +++ b/tests/syntax-tests/highlighted/nix/test.nix @@ -0,0 +1,15 @@ +{ nixpkgs ?  +, nixpkgs' ? import nixpkgs {}}: with nixpkgs'; + +# some comment +stdenv.mkDerivation rec { + pname = "test"; + version = "0.2.3"; + name = "${pname}-${version}"; + + buildInputs = [ + gzip + bzip2 + python27 + ]; +} diff --git a/tests/syntax-tests/highlighted/orgmode/test.org b/tests/syntax-tests/highlighted/orgmode/test.org new file mode 100644 index 00000000..82a9041f --- /dev/null +++ b/tests/syntax-tests/highlighted/orgmode/test.org @@ -0,0 +1,38 @@ +* This is header +** sub header +*** sub sub header +**** sub sub sub header + +* Table representation +| Name | Age | +|---------+-----| +| Milli | 23 | +| Vanilli | 22 | + +* Spreadsheets +| n | n + 2 | n ^ 2 | +|---+-------+-------| +| 1 | 3 | 1 | +| 2 | 4 | 4 | +| 3 | 5 | 9 | +#+TBLFM: $2=$1+2::$3=$1*$1 + +* Source Code + +#+BEGIN_SRC rust + # recursive fibonacci + fn fib(n: u32) -> u32 { + match n { + 0 | 1 => 1, + _ => fib(n - 1) + fib(n - 2), + } + } +#+END_SRC + +* ToDo and Checkboxes Example +** DONE Write source example +** TODO Generate highlighted example [1/3] + - [X] run update script + - [-] get code review + - [ ] merge into master + diff --git a/tests/syntax-tests/highlighted/reStructuredText/reference.rst b/tests/syntax-tests/highlighted/reStructuredText/reference.rst new file mode 100644 index 00000000..4981e15e --- /dev/null +++ b/tests/syntax-tests/highlighted/reStructuredText/reference.rst @@ -0,0 +1,320 @@ +===== +Title +===== + +Subtitle +-------- +Titles are underlined (or over- +and underlined) with a printing +nonalphanumeric 7-bit ASCII +character. Recommended choices +are "``= - ` : ' " ~ ^ _ * + # < >``". +The underline/overline must be at +least as long as the title text. + +A lone top-level (sub)section +is lifted up to be the document's +(sub)title. + +Inline syntaxes +--------------- + +*emphasis*  +**strong emphasis** +`interpreted text` +``inline literal`` +http://docutils.sf.net/ + +Bullet lists +------------ + +- This is item 1 +- This is item 2 + +- Bullets are "-", "*" or "+". + Continuing text must be aligned + after the bullet and whitespace. + +Note that a blank line is required +before the first item and after the +last, but is optional between items. + +Enumerated lists +---------------- +3. This is the first item +4. This is the second item +5. Enumerators are arabic numbers, + single letters, or roman numerals +6. List items should be sequentially + numbered, but need not start at 1 + (although not all formatters will + honour the first index). +#. This item is auto-enumerated + +Definition lists +---------------- + +what + Definition lists associate a term with + a definition. + +how + The term is a one-line phrase, and the + definition is one or more paragraphs or + body elements, indented relative to the + term. Blank lines are not allowed + between term and definition. + +Field lists +----------- +:Authors: + Tony J. (Tibs) Ibbs, + David Goodger + (and sundry other good-natured folks) + +:Version: 1.0 of 2001/08/08 +:Dedication: To my father. + +Options lists +------------- +-a command-line option "a" +-b file options can have arguments + and long descriptions +--long options can be long also +--input=file long options can also have + arguments +/V DOS/VMS-style options too + +Literal Blocks +-------------- + +A paragraph containing only two colons +indicates that the following indented +or quoted text is a literal block. + +:: + + Whitespace, newlines, blank lines, and + all kinds of markup (like *this* or + \this) is preserved by literal blocks. + + The paragraph containing only '::' + will be omitted from the result. + +The ``::`` may be tacked onto the very +end of any paragraph. The ``::`` will be +omitted if it is preceded by whitespace. +The ``::`` will be converted to a single +colon if preceded by text, like this:: + + It's very convenient to use this form. + +Literal blocks end when text returns to +the preceding paragraph's indentation. +This means that something like this +is possible:: + + We start here + and continue here + and end here. + +Per-line quoting can also be used on +unindented literal blocks:: + +> Useful for quotes from email and +> for Haskell literate programming. + +Line blocks +----------- + +A paragraph containing only two colons +indicates that the following indented +or quoted text is a literal block. + +:: + + Whitespace, newlines, blank lines, and + all kinds of markup (like *this* or + \this) is preserved by literal blocks. + + The paragraph containing only '::' + will be omitted from the result. + +The ``::`` may be tacked onto the very +end of any paragraph. The ``::`` will be +omitted if it is preceded by whitespace. +The ``::`` will be converted to a single +colon if preceded by text, like this:: + + It's very convenient to use this form. + +Literal blocks end when text returns to +the preceding paragraph's indentation. +This means that something like this +is possible:: + + We start here + and continue here + and end here. + +Per-line quoting can also be used on +unindented literal blocks:: + +> Useful for quotes from email and +> for Haskell literate programming. + +Block quotes +------------ + +Block quotes are just: + Indented paragraphs, + + and they may nest. + +Doctest blocks +-------------- +Doctest blocks are interactive +Python sessions. They begin with +"``>>>``" and end with a blank line. + +>>> print "This is a doctest block." +This is a doctest block. + +Tables +------ + +Grid table: + ++------------+------------+-----------+ +| Header 1 | Header 2 | Header 3 | ++============+============+===========+ +| body row 1 | column 2 | column 3 | ++------------+------------+-----------+ +| body row 2 | Cells may span columns.| ++------------+------------+-----------+ +| body row 3 | Cells may | - Cells | ++------------+ span rows. | - contain | +| body row 4 | | - blocks. | ++------------+------------+-----------+ + +Simple table: + +===== ===== ====== + Inputs Output +------------ ------ + A B A or B +===== ===== ====== +False False False +True False True +False True True +True True True +===== ===== ====== + +Transitions +----------- + +A transition marker is a horizontal line +of 4 or more repeated punctuation +characters. + +------------ + +A transition should not begin or end a +section or document, nor should two +transitions be immediately adjacent. + +Footnotes +--------- + +Footnote references, like [5]_. +Note that footnotes may get +rearranged, e.g., to the bottom of +the "page". +.. [5] A numerical footnote. Note there's no colon after the ``]``. + +Autonumbered footnotes are +possible, like using [#]_ and [#]_. +.. [#] This is the first one. +.. [#] This is the second one. + +They may be assigned 'autonumber +labels' - for instance, +[#fourth]_ and [#third]_. + +.. [#third] a.k.a. third_ + +.. [#fourth] a.k.a. fourth_ + +Auto-symbol footnotes are also +possible, like this: [*]_ and [*]_. +.. [*] This is the first one. +.. [*] This is the second one. + +Citations +--------- + +Citation references, like [CIT2002]_. +Note that citations may get +rearranged, e.g., to the bottom of +the "page". + +.. [CIT2002] A citation (as often used in journals). + +Citation labels contain alphanumerics, +underlines, hyphens and fullstops. +Case is not significant. + +Given a citation like [this]_, one +can also refer to it like this_. + +.. [this] here. + +Hyperlink Targets +----------------- + +External hyperlinks, like Python_. +.. _Python: http://www.python.org/ + +External hyperlinks, like `Python +`_. + +Internal crossreferences, like example_. +.. _example: + +This is an example crossreference target. + +Python_ is `my favourite +programming language`__. +.. _Python: http://www.python.org/ + +__ Python_ + +Titles are targets, too +======================= +Implict references, like `Titles are +targets, too`_. + +Directives +---------- + +For instance: +.. image:: images/ball1.gif + +The |biohazard| symbol must be used on containers used to dispose of medical waste. +.. |biohazard| image:: biohazard.png + +Comments +-------- + +.. This text will not be shown + (but, for instance, in HTML might be + rendered as an HTML comment) + +An "empty comment" does not +consume following blocks. +(An empty comment is ".." with +blank lines before and after.) +.. + + So this block is not "lost", + despite its indentation. diff --git a/tests/syntax-tests/regression_test.sh b/tests/syntax-tests/regression_test.sh index 25acb256..45e2e3ea 100755 --- a/tests/syntax-tests/regression_test.sh +++ b/tests/syntax-tests/regression_test.sh @@ -4,7 +4,7 @@ set -eou pipefail script_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -output_directory=$(mktemp -d --suffix=.bat-syntax-regression-test) +output_directory=$(mktemp -d) "$script_directory"/create_highlighted_versions.py --output="$output_directory" diff --git a/tests/syntax-tests/source/ASP/test.asp b/tests/syntax-tests/source/ASP/test.asp new file mode 100644 index 00000000..ebb01e82 --- /dev/null +++ b/tests/syntax-tests/source/ASP/test.asp @@ -0,0 +1,36 @@ + + + + +<% +For i = 0 To 5 +Response.Write("The number is " & i & "
") +Next +%> + +<% +Response.Write("Hello World!") +%> + +<% +Dim x(2,2) +x(0,0)="Volvo" +x(0,1)="BMW" +x(0,2)="Ford" +x(1,0)="Apple" +x(1,1)="Orange" +x(1,2)="Banana" +x(2,0)="Coke" +x(2,1)="Pepsi" +x(2,2)="Sprite" +for i=0 to 2 +response.write("

") +for j=0 to 2 +response.write(x(i,j) & "
") +next +response.write("

") +next +%> + + + diff --git a/tests/syntax-tests/source/ActionScript/test.as b/tests/syntax-tests/source/ActionScript/test.as new file mode 100644 index 00000000..f1828bbc --- /dev/null +++ b/tests/syntax-tests/source/ActionScript/test.as @@ -0,0 +1,75 @@ +import flash.events.*; +import flash.events.MouseEvent; + +package TestSyntax { + public class TestSyntax extends flash.display.Sprite { + + public static const TEST_CONSTANT:Number = 33.333; + + var testAttribute:int = 1; + + public namespace TestNamespace; + TestNamespace function Method2():void { } + + /** + * Multi-line comment + */ + override public function set x(value:Number):void + { + super.x = Math.round(value); + } + + /** + * Actual multi-line comment + * Takes up multiple lines + */ + override public function set y(value:Number):void + { + super.y = 0; + } + + public function testFunction() { + var test:String = 'hello'; + + // arrays + var testArray:Array = ["a", "b", "c", "d"]; + for (var i:uint = 0; i < testArray.length; i++) + trace(testArray[i]); + + // objects + var testObject:Object = {foo: 20, bar: 40}; + for (var key:String in testObject) { + trace(testObject[key]); + } + for each (var objectValue:int in testObject) { + trace(objectValue); + } + + // dynamic variables + var testDynamic:*; + testDynamic = 75; + testDynamic = "Seventy-five"; + + // regex + var testRegExp:RegExp = /foo-\d+/i; + + // XML + var testXML:XML = + + Harold + Webster +; + } + + private function anotherFunc(a:int, arg2:uint, arg3:Function, ... args) { + + } + + [Embed(source="sound1.mp3")] public var soundCls:Class; + public function SoundAssetExample() + { + var mySound:SoundAsset = new soundCls() as SoundAsset; + var sndChannel:SoundChannel = mySound.play(); + } + } +} diff --git a/tests/syntax-tests/source/Apache/httpd.conf b/tests/syntax-tests/source/Apache/httpd.conf new file mode 100644 index 00000000..66287352 --- /dev/null +++ b/tests/syntax-tests/source/Apache/httpd.conf @@ -0,0 +1,42 @@ +# This is a comment +# +ServerRoot "" +Listen 80 +LoadModule mpm_event_module /usr/lib/apache2/modules/mod_mpm_event.so + +User daemon +Group daemon + +ServerAdmin you@example.com + + AllowOverride none + Require all denied + +DocumentRoot "/usr/share/apache2/default-site/htdocs" + + Options Indexes FollowSymLinks + AllowOverride None + Require all granted + + + Require all denied + +ErrorLog "/var/log/apache2/error_log" +LogLevel warn + + LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined + CustomLog "/var/log/apache2/access_log" common + + + + ScriptAlias /cgi-bin/ "/usr/lib/cgi-bin/" + + + + TypesConfig /etc/apache2/mime.types + AddType application/x-compress .Z + AddOutputFilter INCLUDES .shtml + + +Include /etc/apache2/extra/proxy-html.conf + diff --git a/tests/syntax-tests/source/AppleScript/test.applescript b/tests/syntax-tests/source/AppleScript/test.applescript new file mode 100644 index 00000000..e739a9ff --- /dev/null +++ b/tests/syntax-tests/source/AppleScript/test.applescript @@ -0,0 +1,25 @@ +-- This is a comment + +property defaultClientName : "Mary Smith" + +on greetClient(nameOfClient) + display dialog ("Hello " & nameOfClient & "!") +end greetClient + + +script testGreet + greetClient(defaultClientName) +end script + +run testGreet +greetClient("Joe Jones") + +set myList to {1, "what", 3} +set beginning of myList to 0 +set end of myList to "four" + +myList + +tell application "TextEdit" + paragraph 1 of document 1 +end tell diff --git a/tests/syntax-tests/source/Assembly (x86_64)/test.nasm b/tests/syntax-tests/source/Assembly (x86_64)/test.nasm new file mode 100644 index 00000000..05c87947 --- /dev/null +++ b/tests/syntax-tests/source/Assembly (x86_64)/test.nasm @@ -0,0 +1,86 @@ +global enlight + +section .data + red dq 0 ; some comment + green dq 0 + blue dq 0 + data dq 0 + N dd 0 + M dd 0 + change dd 0 + delta db 0 + +section .text +enlight: + call assign_arguments + call set_data + call make_deltas + ret + +assign_arguments: + mov qword[red], rdi + mov qword[green], rsi + mov qword[blue], rdx + mov dword[N], ecx + mov dword[M], r8d + mov dword[change], r9d + mov al, byte[rsp + 16] + mov byte[delta], al + ret + +set_data: + mov eax, dword[change] + cmp eax, 1 + jne not_1 + mov rax, qword[red] + mov qword[data], rax + ret +not_1: + cmp eax, 2 + jne not_2 + mov rax, qword[green] + mov qword[data], rax + ret +not_2: + mov rax, qword[blue] + mov qword[data], rax + ret + + +make_deltas: + mov ecx, dword[N] + mov eax, dword[M] + imul ecx, eax +loop_start: + call make_delta + loop loop_start + ret + +make_delta: + mov rax, qword[data] + add rax, rcx + dec rax + mov dl, byte[delta] + cmp dl, 0 + jl substracting +adding: + add dl, byte[rax] + jc adding_overflow + mov byte[rax], dl + ret +adding_overflow: + mov byte[rax], 255 + ret +substracting: + mov r9b, dl + mov dl, 0 + sub dl, r9b + mov r8b, byte[rax] + sub r8b, dl + jc substracting_overflow + mov byte[rax], r8b + ret +; another comment +substracting_overflow: + mov byte[rax], 0 + ret diff --git a/tests/syntax-tests/source/Batch/LICENSE.md b/tests/syntax-tests/source/Batch/LICENSE.md new file mode 100644 index 00000000..299169db --- /dev/null +++ b/tests/syntax-tests/source/Batch/LICENSE.md @@ -0,0 +1,26 @@ +The `build.bat` file has been added from https://github.com/Leandros/ClangOnWindows/blob/master/build.bat under the following license: + +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to \ No newline at end of file diff --git a/tests/syntax-tests/source/Batch/build.bat b/tests/syntax-tests/source/Batch/build.bat new file mode 100644 index 00000000..acf9f7cd --- /dev/null +++ b/tests/syntax-tests/source/Batch/build.bat @@ -0,0 +1,59 @@ +@echo off + + +:: Change to your LLVM installation +set "LLVMPath=C:\Program Files\LLVM" +:: Change to your Visual Studio 2017 installation +set "VSPath=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community" +set "VSVersion=14.10.25017" +:: Change to your Windows Kit version & installation +set "WinSDKVersion=10.0.15063.0" +set "WinSDKPath=C:\Program Files (x86)\Windows Kits\10" +:: Change this to your resulting exe +set "OUTPUT=test.exe" + + +:: Setup +set "VSBasePath=%VSPath%\VC\Tools\MSVC\%VSVersion%" +set "PATH=%PATH%;%LLVMPath%\bin;%VSBasePath%\bin\HostX64\x64" + +:: Compiler Flags +set CFLAGS= ^ + -std=c++14 -Wall -Wextra + +set CPPFLAGS= ^ + -I "%VSBasePath%\include" ^ + -I "%WinSDKPath%\Include\%WinSDKVersion%\shared" ^ + -I "%WinSDKPath%\Include\%WinSDKVersion%\ucrt" ^ + -I "%WinSDKPath%\Include\%WinSDKVersion%\um" + + +:: Linker Libs +set LDFLAGS= ^ + -machine:x64 ^ + -nodefaultlib ^ + -subsystem:console + +set LDLIBS= ^ + -libpath:"%VSBasePath%\lib\x64" ^ + -libpath:"%WinSDKPath%\Lib\%WinSDKVersion%\ucrt\x64" ^ + -libpath:"%WinSDKPath%\Lib\%WinSDKVersion%\um\x64" ^ + libucrt.lib libvcruntime.lib libcmt.lib libcpmt.lib ^ + legacy_stdio_definitions.lib oldnames.lib ^ + legacy_stdio_wide_specifiers.lib ^ + kernel32.lib User32.lib + + +:: Compiling +@echo on +@for %%f in (*.cc) do ( + clang++.exe "%%~f" -o "%%~nf.o" -c %CFLAGS% +) + +:: Linking +@set "LINK_FILES=" +@for %%f in (*.o) do ( + @set "LINK_FILES=%LINK_FILES% %%~f" +) + +lld-link.exe %LINK_FILES% -out:"%OUTPUT%" %LDFLAGS% %LDLIBS% diff --git a/tests/syntax-tests/source/BibTeX/test.bib b/tests/syntax-tests/source/BibTeX/test.bib new file mode 100644 index 00000000..54a1c96d --- /dev/null +++ b/tests/syntax-tests/source/BibTeX/test.bib @@ -0,0 +1,18 @@ +@book{knuth1997art, + title={The art of computer programming}, + author={Knuth, Donald Ervin}, + volume={3}, + year={1997}, + publisher={Pearson Education} +} + +@article{egholm1993pna, + title={PNA hybridizes to complementary oligonucleotides obeying the Watson--Crick hydrogen-bonding rules}, + author={Egholm, Michael and Buchardt, Ole and Christensen, Leif and Behrens, Carsten and Freier, Susan M and Driver, David A and Berg, Rolf H and Kim, Seog K and Norden, Bengt and Nielsen, Peter E}, + journal={Nature}, + volume={365}, + number={6446}, + pages={566--568}, + year={1993}, + publisher={Springer} +} diff --git a/tests/syntax-tests/source/CMake/CMakeLists.txt b/tests/syntax-tests/source/CMake/CMakeLists.txt new file mode 100644 index 00000000..ff894ede --- /dev/null +++ b/tests/syntax-tests/source/CMake/CMakeLists.txt @@ -0,0 +1,16 @@ +# This is a file for testing syntax highlighting. +cmake_minimum_required(VERSION 3.13) +project(hello-bat VERSION 0.0.1 LANGUAGES C) + +set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/") +file(GLOB_RECURSE SOURCES "${SOURCE_DIR}/*.c") + +add_executable(hello-bat SOURCES) + +find_package(assimp CONFIG) +target_link_libraries(hello-bat assimp) + +option("ENABLE_TESTS" OFF) +if(ENABLE_TESTS) + add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/tests/") +endif() diff --git a/tests/syntax-tests/source/CSS/style.css b/tests/syntax-tests/source/CSS/style.css new file mode 100644 index 00000000..48f6267a --- /dev/null +++ b/tests/syntax-tests/source/CSS/style.css @@ -0,0 +1,115 @@ +/*Scrolling*/ +html { scroll-behavior: smooth; } + +/*Header text*/ +.jumbotron { + background-image: linear-gradient(90deg, #849EB5, #30394A); + padding-bottom: 20px; + padding-top: 20px; + text-shadow: 0px 2px 4px #000000; +} + +.container { + margin-top: -25px; +} + +/*Background related*/ +body { + background: #161616; +} + +/*Text related CSS*/ +h4 { + font-size: 70px; + color: #FFFFFF; + font-family: News Cycle, serif; +} + +h3 { + color: #e5e5e5; +} + +p { + font-size: 17px; + font-family: News Cycle, serif; + color: #DEDEDE; +} + +p2 { + font-size: 24px; + color: #DEDEDE; + font-family: News Cycle, serif; +} + +date { + font-family: News Cycle, serif; + font-style: italic; + font-size: 17px; + color: #DEDEDE; +} + +jobtitle { + font-size: 17px; + font-weight: bold; + font-family: News Cycle, serif; + color: #DEDEDE; +} + +jobtilenolink { + font-size: 17px; + font-weight: bold; + font-family: News Cycle, serif; + color: #DEDEDE; +} + +li { + font-family: News Cycle, serif; + color: #DEDEDE; +} + + + +a { + color: #4A8ECC; +} + +p a:visited { + color: #4A8ECC; +} + +.href { + color: #4A8ECC; +} + +a:visited { + color: #4A8ECC; +} + +p a:hover { + color: #4FB1F4; +} + +a:hover { + color: #4FB1F4; +} + +jobtitle:hover { + color: #4FB1F4; +} + +/*Section*/ +section { + background-color: #1B1B1B; + padding: 20px; + margin: -5px; + margin-bottom: 30px; + box-shadow: 0px 2px 4px rgba(0,0,0,0.3); +} + + +/*Icon related*/ +.icon { + position: relative; + top: 3px; + right: 5px; +} diff --git a/tests/syntax-tests/source/CSV/LICENSE.md b/tests/syntax-tests/source/CSV/LICENSE.md new file mode 100644 index 00000000..5585cebf --- /dev/null +++ b/tests/syntax-tests/source/CSV/LICENSE.md @@ -0,0 +1,27 @@ +The `comma_in_quotes.csv` file" has been added from https://github.com/maxogden/csv-spectrum under the following license: + +BSD 2-Clause License + +Copyright (c) [year], [fullname] +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tests/syntax-tests/source/CSV/comma_in_quotes.csv b/tests/syntax-tests/source/CSV/comma_in_quotes.csv new file mode 100644 index 00000000..499ae280 --- /dev/null +++ b/tests/syntax-tests/source/CSV/comma_in_quotes.csv @@ -0,0 +1,7 @@ +first,last,address,city,zip +John,Doe,120 any st.,"Anytown, WW",08123 +a,b +1,"ha +""ha"" +ha",120 any st.,"Anytown, WW",08123 +3,4,120 any st.,"Anytown, WW",08123 diff --git a/tests/syntax-tests/source/Clojure/test.clj b/tests/syntax-tests/source/Clojure/test.clj new file mode 100644 index 00000000..b4010da1 --- /dev/null +++ b/tests/syntax-tests/source/Clojure/test.clj @@ -0,0 +1,58 @@ +(ns clojure-sample.core + (:gen-class)) + + (require '[clj-time.core :as t]) + (require '[clj-time.format :as f]) + + ;; Product record + (defrecord Product [id name available price]) + + ;; Positional constructor + (def product1 (->Product "1" "T-Shirt 1" true 15.00)) + + ;; Map constructor + (def product2 (map->Product + {:id "2" + :name "T-Shirt 2" + :available true + :price 20.00})) + + ;; Nested + (def product3 {:id "1" + :name "Product 1" + :available true + :sellers [{:id "1" + :name "Seller 1" + :stock 3}, + {:id 2 + :name "Seller 2" + :stock 5}]}) + + ;; Set + (def categories #{"shirts" "shoes" "belts"}) + + ;; List + (def wishlist '(1 2)) + + ;; Recursion + (defn factorial [value] (cond + (<= value 1) 1 + :else (* value (factorial (- value 1))))) + + (def basic-formatter (f/formatter "YYYY-MM-dd hh:mm:ss")) + (defn now [] (f/unparse basic-formatter (t/now))) + (defn log + ([] (println (now) "No message")) + ([message] (println (now) message))) + + (defn -main + [& args] + (println (:id product1)) + (println (:name product2)) + (println (:name (get (:sellers product3) 0))) + (println (first categories)) + (println wishlist) + (println (factorial 5)) + (log) + (log "Message")) + diff --git a/tests/syntax-tests/source/CpuInfo/test.CpuInfo b/tests/syntax-tests/source/CpuInfo/test.CpuInfo new file mode 100644 index 00000000..120da39f --- /dev/null +++ b/tests/syntax-tests/source/CpuInfo/test.CpuInfo @@ -0,0 +1,45 @@ +processor : 0 +model name : ARMv7 Processor rev 3 (v7l) +BogoMIPS : 270.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xd08 +CPU revision : 3 + +processor : 1 +model name : ARMv7 Processor rev 3 (v7l) +BogoMIPS : 270.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xd08 +CPU revision : 3 + +processor : 2 +model name : ARMv7 Processor rev 3 (v7l) +BogoMIPS : 270.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xd08 +CPU revision : 3 + +processor : 3 +model name : ARMv7 Processor rev 3 (v7l) +BogoMIPS : 270.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xd08 +CPU revision : 3 + +Hardware : BCM2711 +Revision : b03111 +Serial : 1000000095fd9fc5 +Model : Raspberry Pi 4 Model B Rev 1.1 + diff --git a/tests/syntax-tests/source/Crystal/test.cr b/tests/syntax-tests/source/Crystal/test.cr new file mode 100644 index 00000000..179a5577 --- /dev/null +++ b/tests/syntax-tests/source/Crystal/test.cr @@ -0,0 +1,117 @@ +# An example file to test Crystal syntax highlighting in bat +my_var : Nil = nil +my_var_also : Int32 = 42 +my_other_var = 4.0 +another_float = 4.0_f32 +another_float_2 = 4e10 +another_float_3 = -0.5 +big_one = 1_000_000.111_111e-4 +ternary = 1 > 2 : 3 ? 4 +my_symbol = :ThisOne? +my_other_symbol = :No_That_One! +plus = :+ +minus = :- +my_string : String = "this string right here, with an interpolated value of #{my_var_also}" +my_array : Array(Int32) = [1,2,3,4] +my_tuple : Tuple(Int32, Int32, Int32, Int32) = {1,2,3,4} +my_named_tuple : NamedTuple(one: Int32, two: Int32) = {"one": 1, "two": 2} +my_hash : Hash(String, Int32) = {"one" => 1, "two" => 2} +my_proc : Proc(Int32, Int32) = ->(x : Int32){ x * x} +my_other_proc : Proc(String) = ->{ "Wow, neat!" } +puts my_string +puts(my_string) + +enum Colors + Red + Green + Blue +end + +class Greeter + @instance_field = Colors::Red + @@class_field = Colors::Green + + def initialize(@name = "world") + end + + def greet + puts "Hello, #{@name}" + end + + def render_greeting : String + "Hello, #{@name}" + end + + def with_greeting + yield render_greeting + end + + def is_color_default? + @instance_field == @@class_field + end + + def self.greet_static(name : String) : Unit + puts "Hello, #{name}" + end +end + +greeter = Greeter.new("bat") +greeter.with_greeting do |greeting| + puts greeting +end + +puts <<-EOF + this is a heredoc and it has a value in it of #{greeter.render_greeting}! +EOF + +# This is a command: +`echo yay!` +$?.success? + +my_color = Colors::Red + +puts + case my_color + when Colors::Red, .red? + "Red" + when Colors::Green, .green? + "Green" + when Colors::Blue, .blue? + "Blue" + else + "I dunno, man. Chartreuse? Maroon?" + end + +class MyGenericClass(T) + def initialize(@wrapped_value : T) + end + + def get + return @wrapped_value + end +end + + +def do_stuff_with_range(r : Range(Int|String)) + return if r.empty? + return unless !(r.empty?) + r.each do |item| + if /e/.match(item.to_s) + puts "#{item} contains the letter e!" + elsif item.to_s.empty? + break + else + next # this is unnecessary, but whatever + end + end +end + + +macro print_range(range) + {% for i in range %} + puts {{i.id}} + {% end %} +end + +print_range(1..3) +print_range(1...3) diff --git a/tests/syntax-tests/source/D/test.d b/tests/syntax-tests/source/D/test.d new file mode 100644 index 00000000..534132f5 --- /dev/null +++ b/tests/syntax-tests/source/D/test.d @@ -0,0 +1,44 @@ +// selective import +import std.stdio : writeln, writefln; +// non-selective import +import std.algorithm; + +/* a multiline comment +* +* this function is safe because it doesn't use pointer arithmetic +*/ +int the_ultimate_answer() @safe { + // assert1on + assert(1 != 2); + // now we can safely return our answer + return 42; +} + +void main() +{ + // function call with string literal + writeln("Hello World!"); + + // an int array declaration + int[] arr1 = [1, 2, 3]; + // an immutable double + immutable double pi = 3.14; + // a mutable double + double d1 = pi; + // a pointer + double* dp1 = &d1; + // another pointer to the same thingy + auto a1 = &d1; + // a constant bool + const bool b1 = true; + if (b1) { + // another function call + writefln("%s\n%s\n%s\n", arr1, d1, the_ultimate_answer()); + } + else if (!b1) { + writeln("this seems wrong"); + } + else { + writeln("I'm giving up, this is too crazy for me"); + } +} diff --git a/tests/syntax-tests/source/Diff/82e7786e747b1fcfac1f963ae6415a22ec9caae1.diff b/tests/syntax-tests/source/Diff/82e7786e747b1fcfac1f963ae6415a22ec9caae1.diff new file mode 100644 index 00000000..ebbee60c --- /dev/null +++ b/tests/syntax-tests/source/Diff/82e7786e747b1fcfac1f963ae6415a22ec9caae1.diff @@ -0,0 +1,353 @@ +diff --git a/CHANGELOG.md b/CHANGELOG.md +index ced88213..973eba9a 100644 +--- a/CHANGELOG.md ++++ b/CHANGELOG.md +@@ -2,6 +2,11 @@ + + + ## Features ++ ++- Add a new `--diff` option that can be used to only show lines surrounding ++ Git changes, i.e. added, removed or modified lines. The amount of additional ++ context can be controlled with `--diff-context=N`. See #23 and #940 ++ + ## Bugfixes + ## Other + ## `bat` as a library +diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs +index e5221455..f0f519ea 100644 +--- a/src/bin/bat/app.rs ++++ b/src/bin/bat/app.rs +@@ -15,7 +15,7 @@ use console::Term; + + use bat::{ + assets::HighlightingAssets, +- config::Config, ++ config::{Config, VisibleLines}, + error::*, + input::Input, + line_range::{HighlightedLineRanges, LineRange, LineRanges}, +@@ -196,13 +196,23 @@ impl App { + } + }) + .unwrap_or_else(|| String::from(HighlightingAssets::default_theme())), +- line_ranges: self +- .matches +- .values_of("line-range") +- .map(|vs| vs.map(LineRange::from).collect()) +- .transpose()? +- .map(LineRanges::from) +- .unwrap_or_default(), ++ visible_lines: if self.matches.is_present("diff") { ++ VisibleLines::DiffContext( ++ self.matches ++ .value_of("diff-context") ++ .and_then(|t| t.parse().ok()) ++ .unwrap_or(2), ++ ) ++ } else { ++ VisibleLines::Ranges( ++ self.matches ++ .values_of("line-range") ++ .map(|vs| vs.map(LineRange::from).collect()) ++ .transpose()? ++ .map(LineRanges::from) ++ .unwrap_or_default(), ++ ) ++ }, + style_components, + syntax_mapping, + pager: self.matches.value_of("pager"), +diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs +index c7344991..85edefde 100644 +--- a/src/bin/bat/clap_app.rs ++++ b/src/bin/bat/clap_app.rs +@@ -105,6 +105,34 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { + data to bat from STDIN when bat does not otherwise know \ + the filename."), + ) ++ .arg( ++ Arg::with_name("diff") ++ .long("diff") ++ .help("Only show lines that have been added/removed/modified.") ++ .long_help( ++ "Only show lines that have been added/removed/modified with respect \ ++ to the Git index. Use --diff-context=N to control how much context you want to see.", ++ ), ++ ) ++ .arg( ++ Arg::with_name("diff-context") ++ .long("diff-context") ++ .overrides_with("diff-context") ++ .takes_value(true) ++ .value_name("N") ++ .validator( ++ |n| { ++ n.parse::() ++ .map_err(|_| "must be a number") ++ .map(|_| ()) // Convert to Result<(), &str> ++ .map_err(|e| e.to_string()) ++ }, // Convert to Result<(), String> ++ ) ++ .hidden_short_help(true) ++ .long_help( ++ "Include N lines of context around added/removed/modified lines when using '--diff'.", ++ ), ++ ) + .arg( + Arg::with_name("tabs") + .long("tabs") +@@ -339,6 +367,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { + .takes_value(true) + .number_of_values(1) + .value_name("N:M") ++ .conflicts_with("diff") + .help("Only print the lines from N to M.") + .long_help( + "Only print the specified range of lines for each file. \ +diff --git a/src/config.rs b/src/config.rs +index d5df9910..3c24b77f 100644 +--- a/src/config.rs ++++ b/src/config.rs +@@ -5,6 +5,32 @@ use crate::style::StyleComponents; + use crate::syntax_mapping::SyntaxMapping; + use crate::wrapping::WrappingMode; + ++#[derive(Debug, Clone)] ++pub enum VisibleLines { ++ /// Show all lines which are included in the line ranges ++ Ranges(LineRanges), ++ ++ #[cfg(feature = "git")] ++ /// Only show lines surrounding added/deleted/modified lines ++ DiffContext(usize), ++} ++ ++impl VisibleLines { ++ pub fn diff_context(&self) -> bool { ++ match self { ++ Self::Ranges(_) => false, ++ #[cfg(feature = "git")] ++ Self::DiffContext(_) => true, ++ } ++ } ++} ++ ++impl Default for VisibleLines { ++ fn default() -> Self { ++ VisibleLines::Ranges(LineRanges::default()) ++ } ++} ++ + #[derive(Debug, Clone, Default)] + pub struct Config<'a> { + /// The explicitly configured language, if any +@@ -39,8 +65,8 @@ pub struct Config<'a> { + #[cfg(feature = "paging")] + pub paging_mode: PagingMode, + +- /// Specifies the lines that should be printed +- pub line_ranges: LineRanges, ++ /// Specifies which lines should be printed ++ pub visible_lines: VisibleLines, + + /// The syntax highlighting theme + pub theme: String, +@@ -62,10 +88,7 @@ pub struct Config<'a> { + fn default_config_should_include_all_lines() { + use crate::line_range::RangeCheckResult; + +- assert_eq!( +- Config::default().line_ranges.check(17), +- RangeCheckResult::InRange +- ); ++ assert_eq!(LineRanges::default().check(17), RangeCheckResult::InRange); + } + + #[test] +diff --git a/src/controller.rs b/src/controller.rs +index 09c6ec2a..f636d5fd 100644 +--- a/src/controller.rs ++++ b/src/controller.rs +@@ -1,9 +1,13 @@ + use std::io::{self, Write}; + + use crate::assets::HighlightingAssets; +-use crate::config::Config; ++use crate::config::{Config, VisibleLines}; ++#[cfg(feature = "git")] ++use crate::diff::{get_git_diff, LineChanges}; + use crate::error::*; + use crate::input::{Input, InputReader, OpenedInput}; ++#[cfg(feature = "git")] ++use crate::line_range::LineRange; + use crate::line_range::{LineRanges, RangeCheckResult}; + use crate::output::OutputType; + #[cfg(feature = "paging")] +@@ -68,6 +72,32 @@ impl<'b> Controller<'b> { + no_errors = false; + } + Ok(mut opened_input) => { ++ #[cfg(feature = "git")] ++ let line_changes = if self.config.visible_lines.diff_context() ++ || (!self.config.loop_through && self.config.style_components.changes()) ++ { ++ if let crate::input::OpenedInputKind::OrdinaryFile(ref path) = ++ opened_input.kind ++ { ++ let diff = get_git_diff(path); ++ ++ if self.config.visible_lines.diff_context() ++ && diff ++ .as_ref() ++ .map(|changes| changes.is_empty()) ++ .unwrap_or(false) ++ { ++ continue; ++ } ++ ++ diff ++ } else { ++ None ++ } ++ } else { ++ None ++ }; ++ + let mut printer: Box = if self.config.loop_through { + Box::new(SimplePrinter::new()) + } else { +@@ -75,10 +105,18 @@ impl<'b> Controller<'b> { + &self.config, + &self.assets, + &mut opened_input, ++ #[cfg(feature = "git")] ++ &line_changes, + )) + }; + +- let result = self.print_file(&mut *printer, writer, &mut opened_input); ++ let result = self.print_file( ++ &mut *printer, ++ writer, ++ &mut opened_input, ++ #[cfg(feature = "git")] ++ &line_changes, ++ ); + + if let Err(error) = result { + handle_error(&error); +@@ -96,13 +134,31 @@ impl<'b> Controller<'b> { + printer: &mut dyn Printer, + writer: &mut dyn Write, + input: &mut OpenedInput, ++ #[cfg(feature = "git")] line_changes: &Option, + ) -> Result<()> { + if !input.reader.first_line.is_empty() || self.config.style_components.header() { + printer.print_header(writer, input)?; + } + + if !input.reader.first_line.is_empty() { +- self.print_file_ranges(printer, writer, &mut input.reader, &self.config.line_ranges)?; ++ let line_ranges = match self.config.visible_lines { ++ VisibleLines::Ranges(ref line_ranges) => line_ranges.clone(), ++ #[cfg(feature = "git")] ++ VisibleLines::DiffContext(context) => { ++ let mut line_ranges: Vec = vec![]; ++ ++ if let Some(line_changes) = line_changes { ++ for line in line_changes.keys() { ++ let line = *line as usize; ++ line_ranges.push(LineRange::new(line - context, line + context)); ++ } ++ } ++ ++ LineRanges::from(line_ranges) ++ } ++ }; ++ ++ self.print_file_ranges(printer, writer, &mut input.reader, &line_ranges)?; + } + printer.print_footer(writer, input)?; + +diff --git a/src/pretty_printer.rs b/src/pretty_printer.rs +index 0c78ea90..13bd5dbc 100644 +--- a/src/pretty_printer.rs ++++ b/src/pretty_printer.rs +@@ -6,7 +6,7 @@ use syntect::parsing::SyntaxReference; + + use crate::{ + assets::HighlightingAssets, +- config::Config, ++ config::{Config, VisibleLines}, + controller::Controller, + error::Result, + input::Input, +@@ -205,7 +205,7 @@ impl<'a> PrettyPrinter<'a> { + + /// Specify the lines that should be printed (default: all) + pub fn line_ranges(&mut self, ranges: LineRanges) -> &mut Self { +- self.config.line_ranges = ranges; ++ self.config.visible_lines = VisibleLines::Ranges(ranges); + self + } + +diff --git a/src/printer.rs b/src/printer.rs +index 5eed437e..2b245cfd 100644 +--- a/src/printer.rs ++++ b/src/printer.rs +@@ -24,7 +24,7 @@ use crate::config::Config; + use crate::decorations::LineChangesDecoration; + use crate::decorations::{Decoration, GridBorderDecoration, LineNumberDecoration}; + #[cfg(feature = "git")] +-use crate::diff::{get_git_diff, LineChanges}; ++use crate::diff::LineChanges; + use crate::error::*; + use crate::input::OpenedInput; + use crate::line_range::RangeCheckResult; +@@ -90,7 +90,7 @@ pub(crate) struct InteractivePrinter<'a> { + ansi_prefix_sgr: String, + content_type: Option, + #[cfg(feature = "git")] +- pub line_changes: Option, ++ pub line_changes: &'a Option, + highlighter: Option>, + syntax_set: &'a SyntaxSet, + background_color_highlight: Option, +@@ -101,6 +101,7 @@ impl<'a> InteractivePrinter<'a> { + config: &'a Config, + assets: &'a HighlightingAssets, + input: &mut OpenedInput, ++ #[cfg(feature = "git")] line_changes: &'a Option, + ) -> Self { + let theme = assets.get_theme(&config.theme); + +@@ -145,9 +146,6 @@ impl<'a> InteractivePrinter<'a> { + panel_width = 0; + } + +- #[cfg(feature = "git")] +- let mut line_changes = None; +- + let highlighter = if input + .reader + .content_type +@@ -155,18 +153,6 @@ impl<'a> InteractivePrinter<'a> { + { + None + } else { +- // Get the Git modifications +- #[cfg(feature = "git")] +- { +- use crate::input::OpenedInputKind; +- +- if config.style_components.changes() { +- if let OpenedInputKind::OrdinaryFile(ref path) = input.kind { +- line_changes = get_git_diff(path); +- } +- } +- } +- + // Determine the type of syntax for highlighting + let syntax = assets.get_syntax(config.language, input, &config.syntax_mapping); + Some(HighlightLines::new(syntax, theme)) diff --git a/tests/syntax-tests/source/Dockerfile/Dockerfile b/tests/syntax-tests/source/Dockerfile/Dockerfile new file mode 100644 index 00000000..b38bce26 --- /dev/null +++ b/tests/syntax-tests/source/Dockerfile/Dockerfile @@ -0,0 +1,19 @@ +ARG architecture=amd64 +FROM $architecture/centos:7 +LABEL com.example.version="0.2.1-beta" +ARG architecture + +ENV INTERESTING_PATH /usr/bin/interesting-software + + +COPY entrypoint.sh /usr/bin/entrypoint.sh + +RUN if [ "$architecture" = "i386" ]; then echo "Building i386 docker image" && \ + linux32 yum update -y && linux32 yum install -y mysql ; \ + else yum update -y && yum install -y mysql + +EXPOSE 80/tcp + +VOLUME [/var/lib/mysql/data] + +ENTRYPOINT ["/usr/bin/entrypoint.sh"] diff --git a/tests/syntax-tests/source/DotENV/.env b/tests/syntax-tests/source/DotENV/.env new file mode 100644 index 00000000..42a024ab --- /dev/null +++ b/tests/syntax-tests/source/DotENV/.env @@ -0,0 +1,57 @@ +# Keyword +export TEST_KEYWORD="bar" +export TEST_KEYWORD=12345 +export TEST_KEYWORD=TRUE + +# Variable +TEST_VARIABLE="Hello" + +# String interpolation +TEST_INTERPOLATION_VARIABLE="$VAR1 test test$VAR2test test" +TEST_INTERPOLATION_SYNTAX_ONE="test test{$NVAR1}test{$NVAR2}test test" +TEST_INTERPOLATION_SYNTAX_TWO="test test${NVAR1}test${NVAR2}test test" +TEST_INTERPOLATION_SYNTAX_ALL="test$VAR1test test {VAR2}test test${VAR3}test" + +# Unquoted +TEST_UNQUOTED=bar +TEST_UNQUOTED_NO_VALUE= + +# White spaced +TEST_WHITE_SPACE = +TEST_WHITE_SPACE_STRING = "Hello" +TEST_WHITE_SPACE_UNQUOTED = bar +TEST_WHITE_SPACE_UNQUOTED_BOOL = false +TEST_WHITE_SPACE_UNQUOTED_NUM = 20 + +# language constants +TEST_TRUE=true +TEST_FALSE=false +TEST_NULL=null +TEST_TRUE_CAPITAL=TRUE +TEST_FALSE_CAPITAL=FALSE +TEST_NULL_CAPITAL=NULL + +# Numerical values +TEST_NUM_DECIMAL=54 +TEST_NUM_FLOAT=5.3 +TEST_NUM=1e10 +TEST_NUM_NEGATIVE=-42 +TEST_NUM_OCTAL=057 +TEST_NUM_HEX=0x1A + +# Comments +#TEST_ONE=foobar +# TEST_TWO='foobar' +# TEST_THREE="foobar" # a comment on a commented row +TEST_FOUR="test test test" # this is a comment +TEST_FIVE="comment symbol # inside string" # this is a comment +TEST_SIX="comment symbol # and quotes \" \' inside quotes" # " this is a comment + +# Escape sequences +TEST_ESCAPE="escaped characters \n \t \r \" \' \$ or maybe a backslash \\..." + +# Double Quotes +TEST_DOUBLE="Lorem {$VAR1} ${VAR2} $VAR3 ipsum dolor sit amet\n\r\t\\" + +# Single Quotes +TEST_SINGLE='Lorem {$VAR1} ${VAR2} $VAR3 ipsum dolor sit amet\n\r\t\\' diff --git a/tests/syntax-tests/source/DotENV/LICENSE.md b/tests/syntax-tests/source/DotENV/LICENSE.md new file mode 100644 index 00000000..59d0e293 --- /dev/null +++ b/tests/syntax-tests/source/DotENV/LICENSE.md @@ -0,0 +1,23 @@ +The `.env.test` file has been added from https://github.com/zaynali53/DotENV under the following license: + +The MIT License (MIT) + +Copyright (c) 2016 Zayn Ali + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/tests/syntax-tests/source/Erlang/bat_erlang.erl b/tests/syntax-tests/source/Erlang/bat_erlang.erl new file mode 100644 index 00000000..77d3fffb --- /dev/null +++ b/tests/syntax-tests/source/Erlang/bat_erlang.erl @@ -0,0 +1,72 @@ +-module(bat_erlang). + +-export([main/0]). + +-record(test, { + name :: list(), + data :: binary() +}). + +-define(TESTMACRO, "testmacro"). + +-spec main() -> ok. +main() -> + %% Handling Lists and Numbers + List = [1, 2, 3, 4, $6, 2#00111], + _Sum = lists:sum(List), + _ = [(N * N) + N / N - N || N <- List, N > 2], + [_Head, _SecondHead | _Tail] = List, + _ = [1, atom, [list], <<"binary">>, {tuple, tuple}, #{map => key}, #test{name = "record"}], + + %% Handling Binaries + BinHelloWorld = <<"Hello World">>, + <> <= BinHelloWorld >>, + <<0,0,0,0,0,0,0,151>> = <<151:64/signed-integer>>, + + %% Handling Boolean and Atoms + true = true andalso true, + true = false orelse true, + _ = true =:= true, + _ = false =/= true, + _ = 'HELLO' /= hello, + _ = hello == world, + + %% Handling Maps and Records + TestMap = #{a => 1, b => 2, c => 3}, + #{a := _Value, c := _} = TestMap, + _ = TestMap#{d => 4}, + Record = #test{name = ?TESTMACRO}, + _ = Record#test.name, + + %% Conditionals + case TestMap of + #{b := B} -> + B; + _ -> + ok + end, + if + erlang:is_map(TestMap) -> + map; + true -> + test_function(1) + end, + + %% Messaging + Self = erlang:self(), + Self ! hello_world, + receive + hello_world -> + ok; + _ -> + io:format("unknown message") + after 1000 -> + timeout + end, + ok. + +test_function(N) when erlang:is_integer(N) -> integer; +test_function([_|_]) -> list; +test_function(<<_/binary>>) -> binary; +test_function(_) -> + undefined. diff --git a/tests/syntax-tests/source/EtcGroup/test.group b/tests/syntax-tests/source/EtcGroup/test.group new file mode 100644 index 00000000..68331d73 --- /dev/null +++ b/tests/syntax-tests/source/EtcGroup/test.group @@ -0,0 +1,67 @@ +root:x:0:root +sys:x:3:bin +mem:x:8: +ftp:x:11: +mail:x:12: +log:x:19: +smmsp:x:25: +proc:x:26:polkitd +games:x:50: +lock:x:54: +network:x:90: +floppy:x:94: +scanner:x:96: +power:x:98: +adm:x:999:daemon +wheel:x:998:username +kmem:x:997: +tty:x:5: +utmp:x:996: +audio:x:995:mpd,username +disk:x:994: +input:x:993: +kvm:x:992: +lp:x:991: +optical:x:990:username +render:x:989: +storage:x:988:username +uucp:x:987: +video:x:986:username +users:x:985: +systemd-journal:x:984: +rfkill:x:983: +bin:x:1:daemon +daemon:x:2:bin +http:x:33: +nobody:x:65534: +dbus:x:81: +systemd-journal-remote:x:982: +systemd-network:x:981: +systemd-resolve:x:980: +systemd-timesync:x:979: +systemd-coredump:x:978: +uuidd:x:68: +username:x:1000: +git:x:977: +avahi:x:976: +colord:x:975: +polkitd:x:102: +mpd:x:45: +rtkit:x:133: +transmission:x:169: +wireshark:x:150:username +lightdm:x:974: +geoclue:x:973: +usbmux:x:140: +dhcpcd:x:972: +brlapi:x:971: +gdm:x:120: +libvirt:x:970: +flatpak:x:969: +gluster:x:968: +rpc:x:32: +tor:x:43: +rslsync:x:967: +docker:x:966:username +sambashare:x:1002:username +named:x:40: diff --git a/tests/syntax-tests/source/Fish/test.fish b/tests/syntax-tests/source/Fish/test.fish new file mode 100644 index 00000000..541b2e4f --- /dev/null +++ b/tests/syntax-tests/source/Fish/test.fish @@ -0,0 +1,77 @@ +set fish_greeting "" + +begin + set --local AUTOJUMP_PATH $XDG_CONFIG_HOME/fish/functions/autojump.fish + if test -e $AUTOJUMP_PATH + source $AUTOJUMP_PATH + end +end + +fish_vi_key_bindings + + +function fish_prompt + set_color brblack + echo -n "["(date "+%H:%M")"] " + set_color blue + echo -n (hostname) + if [ $PWD != $HOME ] + set_color brblack + echo -n ':' + set_color yellow + echo -n (basename $PWD) + end + set_color green + printf '%s ' (__fish_git_prompt) + set_color red + echo -n '| ' + set_color normal +end + +function fish_greeting + echo + echo -e (uname -ro | awk '{print " \\\\e[1mOS: \\\\e[0;32m"$0"\\\\e[0m"}') + echo -e (uptime -p | sed 's/^up //' | awk '{print " \\\\e[1mUptime: \\\\e[0;32m"$0"\\\\e[0m"}') + echo -e (uname -n | awk '{print " \\\\e[1mHostname: \\\\e[0;32m"$0"\\\\e[0m"}') + echo -e " \\e[1mDisk usage:\\e[0m" + echo + echo -ne (\ + df -l -h | grep -E 'dev/(xvda|sd|mapper)' | \ + awk '{printf "\\\\t%s\\\\t%4s / %4s %s\\\\n\n", $6, $3, $2, $5}' | \ + sed -e 's/^\(.*\([8][5-9]\|[9][0-9]\)%.*\)$/\\\\e[0;31m\1\\\\e[0m/' -e 's/^\(.*\([7][5-9]\|[8][0-4]\)%.*\)$/\\\\e[0;33m\1\\\\e[0m/' | \ + paste -sd ''\ + ) + echo + + echo -e " \\e[1mNetwork:\\e[0m" + echo + # http://tdt.rocks/linux_network_interface_naming.html + echo -ne (\ + ip addr show up scope global | \ + grep -E ': <|inet' | \ + sed \ + -e 's/^[[:digit:]]\+: //' \ + -e 's/: <.*//' \ + -e 's/.*inet[[:digit:]]* //' \ + -e 's/\/.*//'| \ + awk 'BEGIN {i=""} /\.|:/ {print i" "$0"\\\n"; next} // {i = $0}' | \ + sort | \ + column -t -R1 | \ + # public addresses are underlined for visibility \ + sed 's/ \([^ ]\+\)$/ \\\e[4m\1/' | \ + # private addresses are not \ + sed 's/m\(\(10\.\|172\.\(1[6-9]\|2[0-9]\|3[01]\)\|192\.168\.\).*\)/m\\\e[24m\1/' | \ + # unknown interfaces are cyan \ + sed 's/^\( *[^ ]\+\)/\\\e[36m\1/' | \ + # ethernet interfaces are normal \ + sed 's/\(\(en\|em\|eth\)[^ ]* .*\)/\\\e[39m\1/' | \ + # wireless interfaces are purple \ + sed 's/\(wl[^ ]* .*\)/\\\e[35m\1/' | \ + # wwan interfaces are yellow \ + sed 's/\(ww[^ ]* .*\).*/\\\e[33m\1/' | \ + sed 's/$/\\\e[0m/' | \ + sed 's/^/\t/' \ + ) + echo + set_color normal +end diff --git a/tests/syntax-tests/source/GLSL/test.glsl b/tests/syntax-tests/source/GLSL/test.glsl new file mode 100644 index 00000000..c0dda705 --- /dev/null +++ b/tests/syntax-tests/source/GLSL/test.glsl @@ -0,0 +1,42 @@ +#version 330 core + +#ifdef TEST +layout (location = 0) in vec4 vertex; +#else +layout (location = 6) in vec4 vertex; +#endif + +out vec2 p_textureVertex; + +/* + * This stores offsets + */ +struct Data +{ + double offsetX; + double offsetY; +} + +uniform mat4 projectionMatrix; +uniform bool test; +uniform Data data; + +double calc() +{ + if (test) + { + return 1.0; + } + else + { + return 0.0; + } +} + +void main() +{ + // This GLSL code serves the purpose of bat syntax highlighting tests + double x = data.offsetX + calc(); + gl_Position = projectionMatrix * vec4(vertex.xy, data.offsetX, data.offsetY); + p_textureVertex = vertex.zw; +} diff --git a/tests/syntax-tests/source/Git Attributes/example.gitattributes b/tests/syntax-tests/source/Git Attributes/example.gitattributes new file mode 100644 index 00000000..8b3502b7 --- /dev/null +++ b/tests/syntax-tests/source/Git Attributes/example.gitattributes @@ -0,0 +1,16 @@ +# +# Comment + +[attr]binary -diff -merge -text + +* text=auto +*.c diff=c +*.cc text diff=cpp +*.o binary +*.bat text eol=crlf +*.lock text -diff +*.*ignore text +*.patch -text + +.gitattributes linguist-language=gitattributes +.gitkeep export-ignore diff --git a/tests/syntax-tests/source/Git Config/LICENSE.md b/tests/syntax-tests/source/Git Config/LICENSE.md new file mode 100644 index 00000000..4d51ec63 --- /dev/null +++ b/tests/syntax-tests/source/Git Config/LICENSE.md @@ -0,0 +1 @@ +The `test.gitconfig` file has been added from https://github.com/sharkdp/bat/pull/1336#issuecomment-715905807. Its "free to use". \ No newline at end of file diff --git a/tests/syntax-tests/source/Git Config/text.gitconfig b/tests/syntax-tests/source/Git Config/text.gitconfig new file mode 100644 index 00000000..47224f0b --- /dev/null +++ b/tests/syntax-tests/source/Git Config/text.gitconfig @@ -0,0 +1,107 @@ +[alias] + br = branch + branch = branch -a + c = clone --recursive + ci = commit + cl = clone + co = checkout + contributors = shortlog --summary --numbered + lg = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' + remote = remote -v + st = status + tag = tag -l +[apply] + whitespace = fix +[color] + ui = true +[color "branch"] + current = yellow + local = yellow + remote = green +[color "diff"] + commit = yellow bold + frag = magenta bold + meta = yellow + new = green bold + old = red bold + whitespace = red reverse +[color "diff-highlight"] + newHighlight = green bold 22 + newNormal = green bold + oldHighlight = red bold 52 + oldNormal = red bold +[color "status"] + added = green + changed = yellow + untracked = cyan +[commit] + gpgsign = true +[core] + editor = /usr/bin/vim + # global exclude + excludesfile = /home/frank/.config/git/ignore + pager = delta + ; broken on old machines + untrackedCache = true +[credential] + helper = store +[delta] + features = line-numbers decorations + max-line-length = 1024 + whitespace-error-style = 22 reverse +[delta "decorations"] + commit-decoration-style = bold yellow box ul + file-decoration-style = none + file-style = bold yellow + syntax-theme = gruvbox +[diff] + submodule = diff + algorithm = histogram + renames = copies +[difftool] + prompt = false +[difftool "wrapper"] + binary = true + cmd = git-difftool-wrapper \"$LOCAL\" \"$REMOTE\" +[diff "pdfconv"] + textconv = pdftohtml -stdout +[fetch] + negotiationAlgorithm = skipping + parallel = 0 +[help] + autocorrect = 1 +[index] + version = 4 +[interactive] + diffFilter = delta --color-only +[merge] + log = true +[protocol] + version = 2 +[pull] + rebase = true +[push] + default = current + recurseSubmodules = on-demand +[rebase] + autoStash = true +[rerere] + autoUpdate = true + enabled = true +[sequence] + editor = interactive-rebase-tool +[submodule] + fetchJobs = 0 +[tag] + gpgSign = true + sort = -version:refname +[url "git@gist.github.com:"] + insteadOf = gist: + pushInsteadOf = https://gist.github.com/ +[url "git@github.com:"] + insteadOf = gh: + pushInsteadOf = https://github.com/ +[user] + email = f.nord@example.com + name = Frank Nord + signingkey = AAAAAAAAAAAAAAAA diff --git a/tests/syntax-tests/source/GraphQL/test.graphql b/tests/syntax-tests/source/GraphQL/test.graphql new file mode 100644 index 00000000..6b2f63c0 --- /dev/null +++ b/tests/syntax-tests/source/GraphQL/test.graphql @@ -0,0 +1,145 @@ +# Token:: +# Punctuator +# Name +# IntValue +# FloatValue +# StringValue + +# Punctuator:: one of +# ! $ ( ) ... : = @ [ ] { | } + +# Name:: +# /[_A-Za-z][_0-9A-Za-z]*/ + +# Document : +# Definition (list) + +# Definition : +# ExecutableDefinition +# TypeSystemDefinition +# TypeSystemExtension + +# ExecutableDefinition : +# FragmentDefinition +# OperationDefintion + +# FragmentDefinition + +type someType { + id: ID +} + +fragment subsriberFields on someType { + id + name + fooInt(int: 1234, negInt: -56789, zero: 0) + fooFloat( + float: 1.1 + floatExp: 1.4e10 + floatExpSign1: 1.4e+10 + floatExpSign2: 1.5e-40 + floatExpBigE: 1.5E10 + ) + fooBool(x: true, y: false) + fooString(str: "hello", strUni: "\u2116", strEscWs: "\t") + fooLongStr( + lStr: """ + Hello Reader, + This is a long string block. + Best, + Writer + """ + ) + fooNull(nullThing: null) + fooList(numList: [1, 2, 3], strList: ["a", "b", "c"]) + fooObj(someObj: { str: "hi", int: 2 }) +} + +# OperationDefintion + +query _A1 { + getThings(strArg: "string") { + id # commas here are ignored but valid + name + } +} + +query _A2($x: String) { + someFn(episode: $x) { + name + } +} + +mutation B1 { + changeThings(intArg: 123) { + parent { + nestedField1 + nestedField2 + } + } +} + +subscription C1_Hello { + subsribePlease(floatArg: 1.4) { + id + ...subsriberFields + } +} + +# TypeSystemDefinition : +# SchemaDefinition +# TypeDefinition + +schema { + query: Query + mutation: Mutation +} + +type Query { + """ + Can provide documentation this way. + """ + scalars: Scalars + someList: SomeLists + fooBar: FooBar +} + +interface Thing { + id: ID! +} + +type Scalars implements Thing { + id: ID! + int: Int! + float: Float! + str: String! @deprecated(reason: "Need to test a directive") + bool: Boolean + type: StringTypes +} + +type SomeLists { + ints: [Int!]! +} + +type Foo { + fooVal: String +} + +type Bar { + barVal: String +} + +union FooBar = Foo | Bar + +enum StringTypes { + ONE + TWO +} + +input Xyz { + id: ID! +} + +type Mutation { + createXyz(input: xyz!): Xyz! +} diff --git a/tests/syntax-tests/source/SASS/LICENSE.md b/tests/syntax-tests/source/Graphviz DOT/LICENSE.md similarity index 78% rename from tests/syntax-tests/source/SASS/LICENSE.md rename to tests/syntax-tests/source/Graphviz DOT/LICENSE.md index ee554ef1..3f166cbe 100644 --- a/tests/syntax-tests/source/SASS/LICENSE.md +++ b/tests/syntax-tests/source/Graphviz DOT/LICENSE.md @@ -1,11 +1,8 @@ -This file has been copied from https://sass-lang.com/documentation/syntax +The files `test_digraph.dot` and `test_graph.dot` are modified versions the files from https://github.com/scriptum/graphviz-examples/tree/a7762875efa32f90f6f1a37d866b2c26d362202a under the following license: +The MIT License (MIT) -LICENSE: - - -Copyright (c) 2006-2018 Hampton Catlin, Natalie Weizenbaum, Chris Eppstein, and -Jina Anne +Copyright (c) 2014 Pavel Roschin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -22,4 +19,4 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/tests/syntax-tests/source/Graphviz DOT/test_digraph.dot b/tests/syntax-tests/source/Graphviz DOT/test_digraph.dot new file mode 100644 index 00000000..11e383b4 --- /dev/null +++ b/tests/syntax-tests/source/Graphviz DOT/test_digraph.dot @@ -0,0 +1,41 @@ +digraph { + label =