Struct orgize::export::SyntectHtmlHandler[][src]

pub struct SyntectHtmlHandler<E: From<Error>, H: HtmlHandler<E>> {
    pub syntax_set: SyntaxSet,
    pub theme_set: ThemeSet,
    pub theme: String,
    pub inner: H,
    pub background: IncludeBackground,
    pub error_type: PhantomData<E>,
}
Expand description

Syntect Html Handler

Simple Usage:

use orgize::Org;
use orgize::export::{DefaultHtmlHandler, SyntectHtmlHandler};

let mut handler = SyntectHtmlHandler::new(DefaultHtmlHandler);
let org = Org::parse("src_rust{println!(\"Hello\")}");

let mut vec = vec![];

org.write_html_custom(&mut vec, &mut handler).unwrap();

Customize:

// orgize has re-exported the whole syntect crate
use orgize::syntect::parsing::SyntaxSet;
use orgize::export::{DefaultHtmlHandler, SyntectHtmlHandler};

let mut handler = SyntectHtmlHandler {
    syntax_set: {
        let set = SyntaxSet::load_defaults_newlines();
        let mut builder = set.into_builder();
        // add extra language syntax
        builder.add_from_folder("path/to/syntax/dir", true).unwrap();
        builder.build()
    },
    // specify theme
    theme: String::from("Solarized (dark)"),
    inner: DefaultHtmlHandler,
    ..Default::default()
};

// Make sure to check if theme presents or it will panic at runtime
if handler.theme_set.themes.contains_key("dont-exists") {

}

Fields

syntax_set: SyntaxSet

syntax set, default is SyntaxSet::load_defaults_newlines()

theme_set: ThemeSet

theme set, default is ThemeSet::load_defaults()

theme: String

theme used for highlighting, default is "InspiredGitHub"

inner: H

inner html handler

background: IncludeBackground

background color, default is IncludeBackground::No

error_type: PhantomData<E>

handler error type

Implementations

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.