5 releases (3 breaking)

0.4.0 Apr 27, 2024
0.3.0 Aug 31, 2023
0.2.0 Aug 13, 2023
0.1.1 Jul 4, 2023
0.1.0 Jul 4, 2023

#239 in Parser implementations

Download history 1094/week @ 2024-02-02 1123/week @ 2024-02-09 1551/week @ 2024-02-16 1090/week @ 2024-02-23 1239/week @ 2024-03-01 2108/week @ 2024-03-08 2526/week @ 2024-03-15 2128/week @ 2024-03-22 2278/week @ 2024-03-29 1925/week @ 2024-04-05 2623/week @ 2024-04-12 2004/week @ 2024-04-19 2266/week @ 2024-04-26 2163/week @ 2024-05-03 2462/week @ 2024-05-10 3644/week @ 2024-05-17

10,794 downloads per month
Used in 23 crates (4 directly)


373 lines


build status Crates.io codecov

Dedicated to chasing the bat man

Extra syntax and theme definitions for syntect including many common ones that are missing from the default set like TOML, TypeScript, and Dockerfile. Curated by the bat Project


The following

$ cargo add two-face --features syntect-default-onig
use two_face::re_exports::syntect;

const TOML_TEXT: &str = "\
key = 123

fn main() {
    let syn_set = two_face::syntax::extra_newlines();
    let theme_set = two_face::theme::extra();

    let syn_ref = syn_set.find_syntax_by_extension("toml").unwrap();
    let theme = theme_set.get(two_face::theme::EmbeddedThemeName::Nord);
    let htmlified = syntect::html::highlighted_html_for_string(


will print this

<pre style="background-color:#2e3440;">
<span style="color:#d8dee9;">[section]
</span><span style="color:#81a1c1;">key </span><span style="color:#d8dee9;">= </span><span style="color:#b48ead;">123

Feature Flags

The feature flags are divided by syntect's underlying regex implementation with Oniguruma aka onig being the default and fancy-regex aka fancy as an alternative pure-Rust implementation. fancy: however, doesn't support all of the features used by some of the syntax definitions, so some of the defintions are excluded when fancy is selected* to keep the regex compilation infallible. This means that it's important to match whichever regex implementation syntect is using

* This is also why fancy's bundled syntax definitions are smaller than onig's

default: syntect-onig

Feature Desc.
syntect-onig / syntect-fancy Enables the minimal feature set that we require from syntect
syntect-default-onig / syntect-default-fancy The mimimal feature sets along with syntect's default feature set (useful when using the syntect re-export)

Embedded Asset Sizes

This crate embeds some reasonably large assets in the final binary in order to work. Luckily the linker is smart enough to discard unused assets, so you generally only pay for what you use

For reference here are the sizes associated with their different functions

function two-face (KiB) syntect (KiB)
two_face::acknowledgement::listing() 10 -
two_face::syntax::extra_newlines() (onig) 859 360
^^ (fancy) 804 360
two_face::syntax::extra_no_newlines() (onig) 858 359
^^ (fancy) 803 359
two_face::theme::extra() 45 5

In short the syntax definitions are the real chonky part, and if you're switching from syntect to two-face, then you can expect a ~0.5MiB increase in binary size from them (in exchange for a lot of syntax definitions)


The full listing of all syntaxes included in two_face::syntax

  • * Exluded when using the fancy-regex implementation
  • † Included in syntect's bundled defaults
Syntax Definition
A ActionScript†, Ada, Apache Conf, AppleScript†, AsciiDoc, ASP†, ARM Assembly*, Assembly (x86_64), AWK
B Bash†, Batch File†, BibTeX†
C C†, C#†, C++†, Cabal, Clojure†, CMake, CoffeeScript, Crontab, Crystal, CSS†, CSV†
D D†, Dart, Dockerfile, DotENV, Diff†
E Elixir, Elm, Email, Erlang†
F F#, Fish, Fortran, fstab
G Git (commit, config, ignore, etc.)†, GLSL, Go†, GraphQL, Graphviz (DOT)†, Groff/troff†, Groovy†
H Haskell†, HTML†
J Java†, Javadoc†, Java Server Page (JSP)†, JavaScript†, JavaScript (Babel)*, Jinja2, JQ, JSON†, Julia
K Kotlin
L LaTeX†, LaTeX Log†, Lean, LESS, Lisp†, Literate Haskell†, LiveScript*, LLVM, Lua†
M Makefile†, Manpage, Markdown†, MATLAB†, Mediawiki, MutliMarkdown†
N NAnt Build File†, Nginx, Nim, Ninja, Nix
O Objective-C†, Objective-C++†, OCaml†, OCamllex†, OCamlyacc†, Org Mode
P Pascal†, Perl†, PHP†, PowerShell*, Protobuf, Puppet, PureScript, Python†
R R†, Racket, Rd†, Rego, Regular Expression†, Requirements.txt, reStructuredText†, Robot Framework, Ruby†, Ruby Haml†, Ruby on Rails†, Ruby Slim, Rust†
S Sass*, Scala†, SCSS, Salt State SLS*, SML, Solidity, SQL†, Strace, Stylus, Svelte, Swift, SystemVerilog
T Tcl†, Terraform, TeX†, Textile†, Todo.txt, TOML, TypeScript, TypescriptReact
V Varlink, Verilog, VimL, Vue, Vyper
Z Zig


Note: For visual examples of all of the embedded themes look at the docs for two_face::theme::EmbeddedThemeName

The full listing of themes provided by two_face::theme. Many of these themes only make sense situationally, so you'll likely want to only expose a subset

  • † Included in syntect's bundled defaults
1 1337 (aka leet)
A Ansi
B Base16, Base16-256, Base16-Eighties (dark)†, Base16-Mocha (dark)†, Base16-Ocean (light/dark)†
C Coldark (cold/dark aka light/dark)
D DarkNeon, Dracula
G GitHub, gruvbox (light/dark)
I InspiredGitHub†
M Monokai Extended (plain, bright, light, and origin)
N Nord
O One Half (light/dark)
S Solarized (light/dark)†
T TwoDark
V Visual Studio Dark+
Z Zenburn

Most of the code for generating the syntax and theme dumps along with curating said syntax and themes is taken from bat. Because of this we also mirror bat's licenses by being dual licensed under MIT and Apache-2.0.

See the LICENSE-APACHE and LICENSE-MIT files for license details.

The embedded syntax definitions and assets also have their own licenses which are compiled into this markdown file along with programmatic access in the acknowledgement module.

bat's NOTICE

Copyright (c) 2018-2021 bat-developers (https://github.com/sharkdp/bat).

bat is made available under the terms of either the MIT License or the Apache License 2.0, at your option.

See the LICENSE-APACHE and LICENSE-MIT files for license details.


~146K SLoC