diff options
author | 2024-07-28 19:18:11 +0200 | |
---|---|---|
committer | 2024-07-28 19:18:11 +0200 | |
commit | 1aa0a8fa0d8e5dfe9ab09a11ea7c69f71e19795b (patch) | |
tree | c498256c2cd79f5f3127a6c906460cb7070f3217 /examples/markdown/src | |
parent | 7445b97df5d3d26ea29a19abea6dea3131ae4230 (diff) | |
download | iced-1aa0a8fa0d8e5dfe9ab09a11ea7c69f71e19795b.tar.gz iced-1aa0a8fa0d8e5dfe9ab09a11ea7c69f71e19795b.tar.bz2 iced-1aa0a8fa0d8e5dfe9ab09a11ea7c69f71e19795b.zip |
Enable Markdown highlighting in `markdown` example
Diffstat (limited to 'examples/markdown/src')
-rw-r--r-- | examples/markdown/src/main.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/examples/markdown/src/main.rs b/examples/markdown/src/main.rs index 173cb389..ade6e453 100644 --- a/examples/markdown/src/main.rs +++ b/examples/markdown/src/main.rs @@ -1,3 +1,4 @@ +use iced::highlighter::{self, Highlighter}; use iced::widget::{self, markdown, row, scrollable, text_editor}; use iced::{Element, Fill, Font, Task, Theme}; @@ -63,7 +64,14 @@ impl Markdown { .on_action(Message::Edit) .height(Fill) .padding(10) - .font(Font::MONOSPACE); + .font(Font::MONOSPACE) + .highlight::<Highlighter>( + highlighter::Settings { + theme: highlighter::Theme::Base16Ocean, + token: "markdown".to_owned(), + }, + |highlight, _theme| highlight.to_format(), + ); let preview = markdown(&self.items, markdown::Settings::default()) .map(Message::LinkClicked); |