Debian Codegraph @

examples/syntect.rs

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