highlight

Function highlight 

Source
pub fn highlight(
    context: &mut PrismContext,
    text: &str,
    language: &str,
) -> Option<String>
Expand description

text: the code to be highlighted language: the language to highlight the code in

Example:

use prism_js::{init, highlight};

let mut context = init();

let html = highlight(&mut context, "var foo = true;", "javascript");
assert!(html.is_some());
assert!(html.unwrap() == r#"<span class="token keyword">var</span> foo <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>"#);