[][src]Function syntect::html::tokens_to_classed_spans

pub fn tokens_to_classed_spans(
    line: &str,
    ops: &[(usize, ScopeStackOp)],
    style: ClassStyle
) -> (String, isize)

Output HTML for a line of code with <span> elements specifying classes for each token. The span elements are nested like the scope stack and the scopes are mapped to classes based on the ClassStyle (see it's docs).

See ClassedHTMLGenerator for a more convenient wrapper, this is the advanced version of the function that gives more control over the parsing flow.

For this to work correctly you must concatenate all the lines in a <pre> tag since some span tags opened on a line may not be closed on that line and later lines may close tags from previous lines.

Returns the HTML string and the number of <span> tags opened (negative for closed). So that you can emit the correct number of closing tags at the end.