{"id":16853581,"url":"https://github.com/cosmichorrordev/two-face","last_synced_at":"2025-03-17T05:32:17.525Z","repository":{"id":178127852,"uuid":"661390706","full_name":"CosmicHorrorDev/two-face","owner":"CosmicHorrorDev","description":"Extra syntect syntaxes and themes curated by the bat project","archived":false,"fork":false,"pushed_at":"2025-03-11T06:46:29.000Z","size":6232,"stargazers_count":10,"open_issues_count":6,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T08:31:39.674Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CosmicHorrorDev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-02T17:37:27.000Z","updated_at":"2025-03-11T05:36:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"548a3f0e-bf71-4f0c-b7f0-fe5d06622728","html_url":"https://github.com/CosmicHorrorDev/two-face","commit_stats":null,"previous_names":["cosmichorrordev/two-face"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CosmicHorrorDev%2Ftwo-face","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CosmicHorrorDev%2Ftwo-face/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CosmicHorrorDev%2Ftwo-face/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CosmicHorrorDev%2Ftwo-face/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CosmicHorrorDev","download_url":"https://codeload.github.com/CosmicHorrorDev/two-face/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243981315,"owners_count":20378555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T13:52:08.536Z","updated_at":"2025-03-17T05:32:17.516Z","avatar_url":"https://github.com/CosmicHorrorDev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# _two-face_\n\n[![build status](https://img.shields.io/github/actions/workflow/status/CosmicHorrorDev/two-face/CI.yml?branch=main)](https://github.com/CosmicHorrorDev/two-face/actions)\n[![Crates.io](https://img.shields.io/crates/v/two-face.svg)](https://crates.io/crates/two-face)\n[![codecov](https://codecov.io/gh/CosmicHorrorDev/two-face/graph/badge.svg?token=MUORSBCHF2)](https://codecov.io/gh/CosmicHorrorDev/two-face)\n\n\nDedicated to chasing the [`bat` man](https://github.com/sharkdp)\n\nExtra syntax and theme definitions for\n[`syntect`](https://docs.rs/syntect/latest/syntect/) including many common ones\nthat are missing from the default set like TOML, TypeScript, and Dockerfile.\nCurated by the [`bat` Project](https://github.com/sharkdp/bat)\n\n## Example\n\nThe following\n\n```console\n$ cargo add two-face --features syntect-default-onig\n```\n\n```rust\nuse two_face::re_exports::syntect;\n\nconst TOML_TEXT: \u0026str = \"\\\n[section]\nkey = 123\n\";\n\nfn main() {\n    let syn_set = two_face::syntax::extra_newlines();\n    let theme_set = two_face::theme::extra();\n\n    let syn_ref = syn_set.find_syntax_by_extension(\"toml\").unwrap();\n    let theme = theme_set.get(two_face::theme::EmbeddedThemeName::Nord);\n    let htmlified = syntect::html::highlighted_html_for_string(\n        TOML_TEXT,\n        \u0026syn_set,\n        syn_ref,\n        theme\n    ).unwrap();\n\n    println!(\"{htmlified}\");\n}\n```\n\nwill print this\n\n```html\n\u003cpre style=\"background-color:#2e3440;\"\u003e\n\u003cspan style=\"color:#d8dee9;\"\u003e[section]\n\u003c/span\u003e\u003cspan style=\"color:#81a1c1;\"\u003ekey \u003c/span\u003e\u003cspan style=\"color:#d8dee9;\"\u003e= \u003c/span\u003e\u003cspan style=\"color:#b48ead;\"\u003e123\n\u003c/span\u003e\u003c/pre\u003e\n```\n\n## Feature Flags\n\nThe feature flags are divided by `syntect`'s underlying regex implementation\nwith [`Oniguruma`](https://github.com/kkos/oniguruma) aka `onig` being the\ndefault and [`fancy-regex`](https://github.com/fancy-regex/fancy-regex) aka\n`fancy` as an alternative pure-Rust implementation. `fancy`: however, doesn't\nsupport all of the features used by some of the syntax definitions, so some of\nthe defintions are excluded when `fancy` is selected\\* to keep the regex\ncompilation infallible. This means that it's important to match whichever regex\nimplementation `syntect` is using\n\n_\\* This is also why fancy's bundled syntax definitions are smaller than onig's_\n\ndefault: `syntect-onig`\n\n| Feature | Desc. |\n| :---: | :--- |\n| `syntect-onig` / `syntect-fancy` | Enables the minimal feature set that we require from `syntect` |\n| `syntect-default-onig` / `syntect-default-fancy` | The mimimal feature sets along with `syntect`'s default feature set (useful when using the `syntect` re-export) |\n\n## Embedded Asset Sizes\n\nThis crate embeds some reasonably large assets in the final binary in order to\nwork. Luckily [the linker is smart enough to discard unused assets](https://github.com/CosmicHorrorDev/two-face/blob/0979a0dd5faf2197f6c37ee2194e20bbf0b77ce7/tests/linker_smarts_mixed_partial.rs#L11-L25), so you\ngenerally only pay for what you use\n\nFor reference here are the sizes associated with their different functions\n\n| function | `two-face` (KiB) | `syntect` (KiB) |\n| ---: | ---: | ---: |\n| [`acknowledgement::listing()`](https://docs.rs/two-face/latest/two_face/acknowledgement/fn.listing.html) | 10 | - |\n| [`syntax::extra_newlines()`](https://docs.rs/two-face/latest/two_face/syntax/fn.extra_newlines.html) (onig) | 920 | 360 |\n| ^^ (fancy) | 865 | 360 |\n| [`syntax::extra_no_newlines()`](https://docs.rs/two-face/latest/two_face/syntax/fn.extra_no_newlines.html) (onig) | 919 | 359 |\n| ^^ (fancy) | 864 | 359 |\n| [`theme::extra()`](https://docs.rs/two-face/latest/two_face/theme/index.html) | 45 | 5 |\n\nIn short the syntax definitions are the real chonky part, and if you're\nswitching from `syntect` to `two-face`, then you can expect a ~0.5MiB increase\nin binary size from them (in exchange for _a lot_ of syntax definitions)\n\n## Syntaxes\n\nThe full listing of all syntaxes included in [`two_face::syntax`](https://docs.rs/two-face/latest/two_face/syntax/index.html)\n\n- \\* Excluded when using the `fancy-regex` implementation\n- † Included in `syntect`'s bundled defaults\n\n|  | Syntax Definition |\n| :---: | :---: |\n| A | ActionScript†, Ada, Apache Conf, AppleScript†, AsciiDoc, ASP†, ARM Assembly\\*, Assembly (x86\\_64), AWK |\n| B | Bash†, Batch File†, BibTeX† |\n| C | C†, C#†, C++†, Cabal, CFML, Clojure†, CMake, CoffeeScript, Crontab, Crystal, CSS†, CSV† |\n| D | D†, Dart, Dockerfile, DotENV, Diff† |\n| E | Elixir, Elm, Email, Erlang† |\n| F | F#, Fish, Fortran |\n| G | Git (commit, config, ignore, etc.)†, GLSL, Go†, GraphQL, Graphviz (DOT)†, Groff/troff†, Groovy† |\n| H | Haskell†, HTML† |\n| I | INI |\n| J | Java†, Javadoc†, Java Server Page (JSP)†, JavaScript†, JavaScript (Babel)\\*, Jinja2, JQ, JSON†, Julia |\n| K | Kotlin |\n| L | LaTeX†, LaTeX Log†, Lean, LESS, Lisp†, Literate Haskell†, LiveScript\\*, LLVM, Lua† |\n| M | Makefile†, Manpage, Markdown†, MATLAB†, Mediawiki, MutliMarkdown† |\n| N | NAnt Build File†, Nginx, Nim, Ninja, Nix, NSIS |\n| O | Objective-C†, Objective-C++†, OCaml†, OCamllex†, OCamlyacc†, Org Mode |\n| P | Pascal†, Perl†, PHP†, PowerShell\\*, Protobuf, Puppet, PureScript, Python† |\n| Q | QML |\n| R | R†, Racket, Rd†, Rego, Regular Expression†, Requirements.txt, reStructuredText†, Robot Framework, Ruby†, Ruby Haml†, Ruby on Rails†, Ruby Slim, Rust† |\n| S | Sass\\*, Scala†, SCSS, Salt State SLS\\*, SML, Solidity, SQL†, Strace, Stylus, Svelte, Swift, SystemVerilog |\n| T | Tcl†, Terraform, TeX†, Textile†, Todo.txt, TOML, TypeScript, TypescriptReact |\n| V | Varlink, Verilog, VimL, Vue, Vyper |\n| W | WGSL |\n| X | XML† |\n| Y | YAML† |\n| Z | Zig |\n\n## Themes\n\n_Note: For visual examples of all of the embedded themes look at the docs for\n[`two_face::theme::EmbeddedThemeName`](https://docs.rs/two-face/latest/two_face/theme/enum.EmbeddedThemeName.html)_\n\nThe full listing of themes provided by `two_face::theme`. Many of these themes\nonly make sense situationally, so you'll likely want to only expose a subset\n\n- † Included in `syntect`'s bundled defaults\n\n|  | Theme |\n| :---: | :---: |\n| 1 | 1337 (aka leet) |\n| A | Ansi |\n| B | Base16, Base16-256, Base16-Eighties (dark)†, Base16-Mocha (dark)†, Base16-Ocean (light/dark)† |\n| C | Coldark (cold/dark aka light/dark) |\n| D | DarkNeon, Dracula |\n| G | GitHub, gruvbox (light/dark) |\n| I | InspiredGitHub† |\n| M | Monokai Extended (plain, bright, light, and origin) |\n| N | Nord |\n| O | One Half (light/dark) |\n| S | Solarized (light/dark)†, Sublime Snazzy |\n| T | TwoDark |\n| V | Visual Studio Dark+ |\n| Z | Zenburn |\n\n## Legal\n\nMost of the code for generating the syntax and theme dumps along with curating\nsaid syntax and themes is taken from [`bat`](https://github.com/sharkdp/bat).\nBecause of this we also mirror `bat`'s licenses by being dual licensed under MIT\nand Apache-2.0.\n\nSee the [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) files\nfor license details.\n\nThe embedded syntax definitions and assets also have their own licenses which\nare compiled into\n[this markdown file](https://github.com/CosmicHorrorDev/two-face/blob/main/generated/acknowledgements_full.md)\nalong with programmatic access in the `acknowledgement` module.\n\n### `bat`'s NOTICE\n\nCopyright (c) 2018-2021 bat-developers (https://github.com/sharkdp/bat).\n\nbat is made available under the terms of either the MIT License or the Apache\nLicense 2.0, at your option.\n\nSee the [LICENSE-APACHE](./bat/LICENSE-APACHE) and\n[LICENSE-MIT](./bat/LICENSE-MIT) files for license details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosmichorrordev%2Ftwo-face","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcosmichorrordev%2Ftwo-face","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosmichorrordev%2Ftwo-face/lists"}