pub fn line_tokens_to_classed_spans(
line: &str,
ops: &[(usize, ScopeStackOp)],
style: ClassStyle,
stack: &mut ScopeStack,
) -> Result<(String, isize), Error>
Expand description
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.