Crate treelight

Crate treelight 

Source
Expand description

Version Downloads License Docs crev reviews

A syntax highlighter for the web using tree-sitter.

use treelight::*;

let code = r#"
use thiserror::Error;

#[derive(Error, Debug)]
pub enum ResponseError {
    #[error("api error {0}")]
    ApiError(#[from] PaypalError),
    #[error("http error {0}")]
    HttpError(#[from] reqwest::Error)
}
"#;

let result = highlight_to_html(Language::Rust, code);
println!("{}", result);

Modules§

bash
c
c_sharp
cpp
go
haskell
java
javascript
json
julia
php
python
ruby
rust
scala
typescript

Enums§

Language
The list of supported languages

Statics§

HIGHLIGHT_NAMES
The recognized highlight names, when parsing the code to HTML, the spans will have this name within the class attribute, with the dots replaced by -, for example punctuation.delimiter will become <span class="punctuation-delimiter">code here...</span>.

Functions§

highlight_to_html