Git Product home page Git Product logo

two-face's Introduction

two-face

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

Example

The following

[dependencies]
syntect = "0.5.1"
two-face = "0.2.0"
const TOML_TEXT: &str = "\
[section]
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(
        TOML_TEXT,
        &syn_set,
        syn_ref,
        theme
    ).unwrap();

    println!("{htmlified}");
}

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
</span></pre>

Feature Flags

Some embedded syntaxes use features that aren't available with fancy-regex. To keep regex compilation infallible it's important to match this library's regex implementation with the one you're using from syntect

To use Oniguruma aka onig

[dependencies]
# `onig` is the default
syntect = "0.5.1"
two-face = "0.2.0"

To use fancy-regex

[dependencies]
syntect = { version = "0.5.1", default-features = false, features = ["default-fancy"] }
two-face = { version = "0.2.0", default-features = false, features = ["syntect-fancy"] }

Legal

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.

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.

two-face's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

two-face's Issues

Short term

Dumping here since I'm too busy to work on this for the next few weeks

  • Setup CI
    • Test over a decent set of feature flags
    • Could track code cov
    • Allow cutting a release from CI
    • Make sure to also test just the crate, so that feature unification from xtask doesn't foul things up
  • Expand tests heavily
    • Would be cool to add a test that keeps track of embedded asset sizes
  • Have newline and no newline variants for syntaxes (separate feature for each)
  • Add an enum that enumerates all the themes contained in the provided set
    • You should be able to infallibly access a theme by enum variant
  • Add a release checklist since releases are non-trivial

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.