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, Theme::TokyoNight)
            .map(Message::LinkClicked)
            .into()
    }

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

Structs§

Content
A bunch of Markdown that has been parsed.
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.
Viewer
A view strategy to display a Markdown Item.j

Functions§

code_block
Displays a code block using the default look.
heading
Displays a heading using the default look.
item
Displays an Item using the given Viewer.
ordered_list
Displays an ordered list using the default look and calling the Viewer for each numbered item.
paragraph
Displays a paragraph using the default look.
parse
Parse the given Markdown content.
unordered_list
Displays an unordered list using the default look and calling the Viewer for each bullet point item.
view
Display a bunch of Markdown items.
view_with
Runs view but with a custom Viewer to turn an Item into an Element.