#render #traits #unimarkup #markup #html #rendering #elements

unimarkup-render

Crate providing traits and types used for rendering Unimarkup markup

1 unstable release

0.4.0 Apr 23, 2023

#101 in #markup

Download history 10/week @ 2024-02-19 23/week @ 2024-02-26 10/week @ 2024-03-04 14/week @ 2024-03-11 4/week @ 2024-03-18 11/week @ 2024-03-25 35/week @ 2024-04-01 3/week @ 2024-04-08 32/week @ 2024-04-15

81 downloads per month
Used in 4 crates (2 directly)

MIT license

9KB
62 lines

Unimarkup Render

This crate defines types and traits used in the inline and core crate to render Unimarkup elements to all supported output formats. Therefore, all Unimarkup elements must implement the Render trait defined in this crate.

Add a new Unimarkup Element

Newly added Unimarkup elements must implement the Render trait.

impl Render for NewElement {
  fn render_html(&self) -> Result<Html, LogId> {
    // implement rendering to HTML for this new element
  }
}

Add a new Output Format

To add a new output format, the Render trait must be extended.

Note: This affects all Unimarkup elements implementing the Render trait!

pub trait Render {
  // ...
  // previous output formats
  // ...

  /// Renders Unimarkup to the new output format
  fn render_new_format(&self) => Result<NewFormat, LogId>;
}

Syntax Highlighting

The crate also provides syntax highlighting functionality in the highlight module using the syntect crate.

Dependencies

~6–15MB
~169K SLoC