From 1aa0a8fa0d8e5dfe9ab09a11ea7c69f71e19795b Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 28 Jul 2024 19:18:11 +0200 Subject: Enable Markdown highlighting in `markdown` example --- examples/markdown/src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'examples/markdown/src') 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::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); -- cgit