Struct Html

Source
pub struct Html { /* private fields */ }
Expand description

HTML renderer

This can be used to render markdown documents to HTML. This type can also be leveraged to create custom renderers that delegate to the HTML renderer in certain cases, as shown in the Render trait documentation example.

let input = Buffer::from("EMPHASIZE");
let mut output = Buffer::new(64usize);
let mut html_renderer = Html::new(Flags::empty(), 0);

html_renderer.emphasis(&mut output, Some(&input));

assert_eq!(output.to_str().unwrap(), "<em>EMPHASIZE</em>");

Implementations§

Source§

impl Html

Source

pub fn new(flags: Flags, nesting_level: i32) -> Html

Construct a new html renderer given the provided html flags and table of contents nesting level.

The toc method can be used to construct a table of contents renderer which renders only the table of contents. The nesting_level on this method determines the maximum depth of headers to associate with the table of contents.

For this reason, if a table of contents is going to be rendered, this method’s nesting_level argument should be the same as the one passed to the toc method.

Source

pub fn toc(nesting_level: i32) -> Html

Construct a table of contents renderer.

This renderer will only render the table of contents. If you want to have the headers of the document specify id attributes so that the table of contents items link to the correct header, you should render the document with the renderer returned by the new method with the same value for the nesting_level parameter.

Source

pub fn get(&self) -> &hoedown_renderer

Get a reference to the underlying hoedown renderer

Source

pub fn as_mut(&mut self) -> &mut hoedown_renderer

Get a mutable reference to the underlying hoedown renderer

Trait Implementations§

Source§

impl Drop for Html

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Render for Html

Source§

unsafe fn to_hoedown(&mut self) -> hoedown_renderer

Converts the type into an underlying hoedown_renderer structure. Read more
Source§

fn code_block( &mut self, ob: &mut Buffer, text: Option<&Buffer>, lang: Option<&Buffer>, )

Runs when a codeblock is encountered Read more
Source§

fn quote_block(&mut self, ob: &mut Buffer, content: Option<&Buffer>)

Runs when a block quote is encountered Read more
Source§

fn header(&mut self, ob: &mut Buffer, content: Option<&Buffer>, level: i32)

Runs when a header is encountered Read more
Source§

fn horizontal_rule(&mut self, ob: &mut Buffer)

Runs when a horizontal rule is encountered Read more
Source§

fn list(&mut self, ob: &mut Buffer, content: Option<&Buffer>, flags: List)

Runs when a list is encountered. Read more
Source§

fn list_item(&mut self, ob: &mut Buffer, content: Option<&Buffer>, flags: List)

Runs when a list item is encountered. Read more
Source§

fn paragraph(&mut self, ob: &mut Buffer, content: Option<&Buffer>)

Runs when a paragraph is encountered. Read more
Source§

fn table(&mut self, ob: &mut Buffer, content: Option<&Buffer>)

Runs when a table is encountered. Read more
Source§

fn table_header(&mut self, ob: &mut Buffer, content: Option<&Buffer>)

Runs when a table header is encountered. Read more
Source§

fn table_body(&mut self, ob: &mut Buffer, content: Option<&Buffer>)

Runs when a table body is encountered. Read more
Source§

fn table_row(&mut self, ob: &mut Buffer, content: Option<&Buffer>)

Runs when a table row is encountered. Read more
Source§

fn table_cell( &mut self, ob: &mut Buffer, content: Option<&Buffer>, flags: Table, )

Runs when a table cell is encountered. Read more
Source§

fn footnotes(&mut self, ob: &mut Buffer, content: Option<&Buffer>)

Runs when footnotes are encountered. Read more
Source§

fn footnote_definition( &mut self, ob: &mut Buffer, content: Option<&Buffer>, num: u32, )

Runs when a footnote definition is encountered. Read more
Source§

fn html_block(&mut self, ob: &mut Buffer, text: Option<&Buffer>)

Runs when a raw html block is encountered. Read more
Runs when an autolink candidate is encountered. Read more
Source§

fn code_span(&mut self, ob: &mut Buffer, text: Option<&Buffer>) -> bool

Runs when a code span is encountered. Read more
Source§

fn double_emphasis(&mut self, ob: &mut Buffer, content: Option<&Buffer>) -> bool

Runs when double emphasis is encountered. Read more
Source§

fn emphasis(&mut self, ob: &mut Buffer, content: Option<&Buffer>) -> bool

Runs when emphasis is encountered. Read more
Source§

fn underline(&mut self, ob: &mut Buffer, content: Option<&Buffer>) -> bool

Runs when underline is encountered. Read more
Source§

fn highlight(&mut self, ob: &mut Buffer, content: Option<&Buffer>) -> bool

Runs when highlight is encountered. Read more
Source§

fn quote_span(&mut self, ob: &mut Buffer, content: Option<&Buffer>) -> bool

Runs when a quote is encountered. Read more
Source§

fn image( &mut self, ob: &mut Buffer, link: Option<&Buffer>, title: Option<&Buffer>, alt: Option<&Buffer>, ) -> bool

Runs when an image is encountered. Read more
Source§

fn line_break(&mut self, ob: &mut Buffer) -> bool

Runs when a line break is encountered. Read more
Runs when a link is encountered. Read more
Source§

fn triple_emphasis(&mut self, ob: &mut Buffer, content: Option<&Buffer>) -> bool

Runs when triple emphasis is encountered. Read more
Source§

fn strikethrough(&mut self, ob: &mut Buffer, content: Option<&Buffer>) -> bool

Runs when strikethrough is encountered. Read more
Source§

fn superscript(&mut self, ob: &mut Buffer, content: Option<&Buffer>) -> bool

Runs when superscript is encountered. Read more
Source§

fn footnote_reference(&mut self, ob: &mut Buffer, num: u32) -> bool

Runs when a footnote reference is encountered. Read more
Source§

fn math( &mut self, ob: &mut Buffer, text: Option<&Buffer>, displaymode: i32, ) -> bool

Runs when math is encountered. Read more
Source§

fn html_span(&mut self, ob: &mut Buffer, text: Option<&Buffer>) -> bool

Runs when raw html span is encountered. Read more
Source§

fn entity(&mut self, ob: &mut Buffer, text: Option<&Buffer>)

Runs when an html entity is encountered. Read more
Source§

fn normal_text(&mut self, ob: &mut Buffer, text: Option<&Buffer>)

Runs when plain text is encountered. Read more
Source§

fn before_render(&mut self, ob: &mut Buffer, inline_render: bool)

Runs before the document is processed. Read more
Source§

fn after_render(&mut self, ob: &mut Buffer, inline_render: bool)

Runs after the document has been processed. Read more
Source§

fn render(&mut self, input: &Markdown) -> Buffer

Render the document to a buffer that is returned
Source§

fn render_to(&mut self, input: &Markdown, output: &mut Buffer)

Render the document into the given buffer
Source§

fn render_inline(&mut self, input: &Markdown) -> Buffer

Render the document as inline to a buffer that is returned
Source§

fn render_inline_to(&mut self, input: &Markdown, output: &mut Buffer)

Render the document as inline into the given buffer

Auto Trait Implementations§

§

impl Freeze for Html

§

impl RefUnwindSafe for Html

§

impl !Send for Html

§

impl !Sync for Html

§

impl Unpin for Html

§

impl UnwindSafe for Html

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.