Module markdown

Source
Available on crate feature markdown only.
Expand description

Markdown widgets can parse and display Markdown.

You can enable the highlighter feature for syntax highlighting in code blocks.

Only the variants of Item are currently supported.

§Example

use iced::widget::markdown;
use iced::Theme;

struct State {
   markdown: Vec<markdown::Item>,
}

enum Message {
    LinkClicked(markdown::Url),
}

impl State {
    pub fn new() -> Self {
        Self {
            markdown: markdown::parse("This is some **Markdown**!").collect(),
        }
    }

    fn view(&self) -> Element<'_, Message> {
        markdown::view(
            &self.markdown,
            markdown::Settings::default(),
            markdown::Style::from_palette(Theme::TokyoNightStorm.palette()),
        )
        .map(Message::LinkClicked)
        .into()
    }

    fn update(state: &mut State, message: Message) {
        match message {
            Message::LinkClicked(url) => {
                println!("The following url was clicked: {url}");
            }
        }
    }
}

Structs§

Highlight
A text highlight.
Settings
Configuration controlling Markdown rendering in view.
Style
The text styling of some Markdown rendering in view.
Text
A bunch of parsed Markdown text.
Url
A parsed URL record.

Enums§

HeadingLevel
Item
A Markdown item.

Traits§

Catalog
The theme catalog of Markdown items.

Functions§

parse
Parse the given Markdown content.
view
Display a bunch of Markdown items.