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§
- 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
Item
using the givenViewer
. - 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 customViewer
to turn anItem
into anElement
.