[−][src]Struct syntect::html::ClassedHTMLGenerator
Output HTML for a line of code with <span>
elements using class names
As this has to keep track of open and closed <span>
tags, it is a struct
with additional state.
There is a finalize()
function that has to be called in the end in order
to close all open <span>
tags.
The lines returned don't include a newline at the end.
Example
use syntect::html::ClassedHTMLGenerator; use syntect::parsing::SyntaxSet; let current_code = r#" x <- 5 y <- 6 x + y "#.to_string(); let syntax_set = SyntaxSet::load_defaults_newlines(); let syntax = syntax_set.find_syntax_by_name("R").unwrap(); let mut html_generator = ClassedHTMLGenerator::new(&syntax, &syntax_set); for line in current_code.lines() { html_generator.parse_html_for_line(&line); } let output_html = html_generator.finalize();
Implementations
impl<'a> ClassedHTMLGenerator<'a>
[src]
pub fn new(
syntax_reference: &'a SyntaxReference,
syntax_set: &'a SyntaxSet
) -> ClassedHTMLGenerator<'a>
[src]
syntax_reference: &'a SyntaxReference,
syntax_set: &'a SyntaxSet
) -> ClassedHTMLGenerator<'a>
pub fn parse_html_for_line(&mut self, line: &str)
[src]
Parse the line of code and update the internal HTML buffer with tagged HTML
pub fn finalize(self) -> String
[src]
Close all open <span>
tags and return the finished HTML string
Auto Trait Implementations
impl<'a> !RefUnwindSafe for ClassedHTMLGenerator<'a>
impl<'a> !Send for ClassedHTMLGenerator<'a>
impl<'a> !Sync for ClassedHTMLGenerator<'a>
impl<'a> Unpin for ClassedHTMLGenerator<'a>
impl<'a> !UnwindSafe for ClassedHTMLGenerator<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,