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::Uri),
}
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§
- Column
- The column of a table.
- Content
- A bunch of Markdown that has been parsed.
- Highlight
- A text highlight.
- Row
- The row of a table.
- Settings
- Configuration controlling Markdown rendering in
view. - Style
- The text styling of some Markdown rendering in
view. - Text
- A bunch of parsed Markdown text.
Enums§
- Bullet
- The item of a list.
- Heading
Level - Item
- A Markdown item.
Traits§
Functions§
- code_
block - Displays a code block using the default look.
- heading
- Displays a heading using the default look.
- item
- Displays an
Itemusing the givenViewer. - items
- Displays a column of items with the default look.
- ordered_
list - Displays an ordered list using the default look and
calling the
Viewerfor each numbered item. - paragraph
- Displays a paragraph using the default look.
- parse
- Parse the given Markdown content.
- quote
- Displays a quote using the default look.
- rule
- Displays a rule using the default look.
- table
- Displays a table using the default look.
- unordered_
list - Displays an unordered list using the default look and
calling the
Viewerfor each bullet point item. - view
- Display a bunch of Markdown items.
- view_
with - Runs
viewbut with a customViewerto turn anIteminto an [Element].