Struct SyntectWriter

Source
pub struct SyntectWriter<'a, W>
where W: 'a + StrWrite,
{ /* private fields */ }
Expand description

An HTML writer implementation. This type implements methods for writing HTML elements. Writer that adds syntax highlighting to code blocks

Implementations§

Source§

impl<'a, W: StrWrite> SyntectWriter<'a, W>

Source

pub fn new(writer: W, config: &'a HtmlConfig) -> Self

Source

pub fn with_custom_sets( writer: W, config: &'a HtmlConfig, syntax_set: Option<&'a SyntaxSet>, theme_set: Option<&'a ThemeSet>, ) -> Self

Source

pub fn get_theme_css(&self) -> Result<String, String>

Trait Implementations§

Source§

impl<'a, W> HtmlWriter<W> for SyntectWriter<'a, W>
where W: 'a + StrWrite,

Source§

fn get_writer(&mut self) -> &mut W

Source§

fn get_config(&self) -> &HtmlConfig

Source§

fn get_state(&mut self) -> &mut HtmlState

Source§

fn write_str(&mut self, s: &str) -> Result<(), HtmlError>

Write a string directly to the output
Source§

fn write_attributes(&mut self, element: &str) -> Result<(), HtmlError>

Write HTML attributes for a given element
Check if a URL points to an external resource
Source§

fn start_paragraph(&mut self) -> Result<(), HtmlError>

Source§

fn end_paragraph(&mut self) -> Result<(), HtmlError>

Source§

fn start_heading( &mut self, level: HeadingLevel, id: Option<&str>, classes: &[CowStr<'_>], attrs: &Vec<(CowStr<'_>, Option<CowStr<'_>>)>, ) -> Result<(), HtmlError>

Source§

fn end_heading(&mut self, level: HeadingLevel) -> Result<(), HtmlError>

Source§

fn start_blockquote(&mut self) -> Result<(), HtmlError>

Source§

fn end_blockquote(&mut self) -> Result<(), HtmlError>

Source§

fn start_code_block(&mut self, kind: CodeBlockKind<'_>) -> Result<(), HtmlError>

Source§

fn end_code_block(&mut self) -> Result<(), HtmlError>

Source§

fn start_inline_code(&mut self) -> Result<(), HtmlError>

Source§

fn end_inline_code(&mut self) -> Result<(), HtmlError>

Source§

fn start_list(&mut self, first_number: Option<u64>) -> Result<(), HtmlError>

Source§

fn end_list(&mut self, ordered: bool) -> Result<(), HtmlError>

Source§

fn start_list_item(&mut self) -> Result<(), HtmlError>

Source§

fn end_list_item(&mut self) -> Result<(), HtmlError>

Source§

fn start_table(&mut self, alignments: Vec<Alignment>) -> Result<(), HtmlError>

Source§

fn end_table(&mut self) -> Result<(), HtmlError>

Source§

fn start_table_head(&mut self) -> Result<(), HtmlError>

Source§

fn end_table_head(&mut self) -> Result<(), HtmlError>

Source§

fn start_table_row(&mut self) -> Result<(), HtmlError>

Source§

fn end_table_row(&mut self) -> Result<(), HtmlError>

Source§

fn start_table_cell(&mut self) -> Result<(), HtmlError>

Source§

fn end_table_cell(&mut self) -> Result<(), HtmlError>

Source§

fn start_emphasis(&mut self) -> Result<(), HtmlError>

Source§

fn end_emphasis(&mut self) -> Result<(), HtmlError>

Source§

fn start_strong(&mut self) -> Result<(), HtmlError>

Source§

fn end_strong(&mut self) -> Result<(), HtmlError>

Source§

fn start_strikethrough(&mut self) -> Result<(), HtmlError>

Source§

fn end_strikethrough(&mut self) -> Result<(), HtmlError>

Source§

fn start_image<'a, I>( &mut self, _link_type: LinkType, dest: &str, title: &str, iter: &mut Peekable<I>, ) -> Result<(), HtmlError>
where I: Iterator<Item = Event<'a>>,

Source§

fn end_image(&mut self) -> Result<(), HtmlError>

Source§

fn footnote_reference(&mut self, name: &str) -> Result<(), HtmlError>

Source§

fn start_footnote_definition(&mut self, name: &str) -> Result<(), HtmlError>

Source§

fn end_footnote_definition(&mut self) -> Result<(), HtmlError>

Source§

fn task_list_item(&mut self, checked: bool) -> Result<(), HtmlError>

Source§

fn horizontal_rule(&mut self) -> Result<(), HtmlError>

Source§

fn soft_break(&mut self) -> Result<(), HtmlError>

Source§

fn hard_break(&mut self) -> Result<(), HtmlError>

Source§

fn text(&mut self, text: &str) -> Result<(), HtmlError>

Source§

fn start_definition_list(&mut self) -> Result<(), HtmlError>

Source§

fn end_definition_list(&mut self) -> Result<(), HtmlError>

Source§

fn start_definition_list_title(&mut self) -> Result<(), HtmlError>

Source§

fn end_definition_list_title(&mut self) -> Result<(), HtmlError>

Source§

fn start_definition_list_definition(&mut self) -> Result<(), HtmlError>

Source§

fn end_definition_list_definition(&mut self) -> Result<(), HtmlError>

Source§

fn start_metadata_block( &mut self, _metadata_type: &MetadataBlockKind, ) -> Result<(), HtmlError>

Source§

fn end_metadata_block(&mut self) -> Result<(), HtmlError>

Source§

fn html_raw(&mut self, html: &CowStr<'_>) -> Result<(), HtmlError>

Source§

fn collect_alt_text<'a, I>(&self, iter: &mut Peekable<I>) -> String
where I: Iterator<Item = Event<'a>>,

Auto Trait Implementations§

§

impl<'a, W> Freeze for SyntectWriter<'a, W>
where W: Freeze,

§

impl<'a, W> RefUnwindSafe for SyntectWriter<'a, W>
where W: RefUnwindSafe,

§

impl<'a, W> Send for SyntectWriter<'a, W>
where W: Send,

§

impl<'a, W> Sync for SyntectWriter<'a, W>
where W: Sync,

§

impl<'a, W> Unpin for SyntectWriter<'a, W>
where W: Unpin,

§

impl<'a, W> UnwindSafe for SyntectWriter<'a, W>
where W: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.