1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
//! This example shows how to use the bundled syntect plugin.
#![cfg(feature="syntect")]
use comrak::plugins::syntect::SyntectAdapterBuilder;
use comrak::{markdown_to_html_with_plugins, Options, Plugins};
fn main() {
run_with(SyntectAdapterBuilder::new().theme("base16-ocean.dark"));
run_with(SyntectAdapterBuilder::new().css());
}
fn run_with(builder: SyntectAdapterBuilder) {
let adapter = builder.build();
let options = Options::default();
let mut plugins = Plugins::default();
plugins.render.codefence_syntax_highlighter = Some(&adapter);
let input = concat!("```Rust\n", "fn main<'a>();\n", "```");
let formatted = markdown_to_html_with_plugins(input, &options, &plugins);
println!("{}", formatted);
}
|