Module markdown
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§
- A text highlight.
- Configuration controlling Markdown rendering in
view
. - The text styling of some Markdown rendering in
view
. - A bunch of parsed Markdown text.
- A parsed URL record.
Enums§
- A Markdown item.
Traits§
- The theme catalog of Markdown items.
Functions§
- Parse the given Markdown content.
- Display a bunch of Markdown items.