From bba8ec664bfdf242b1f0c5caaaac2f388d59b70e Mon Sep 17 00:00:00 2001 From: Erlend Walstad <96946613+lampsitter@users.noreply.github.com> Date: Sat, 7 Sep 2024 19:45:47 +0200 Subject: [PATCH] Always stop code text style On the start of a code block the code text style was enabled. However upon ending the code block, the style was only disabled for _fenced_ code blocks. This prevents the code style from bleeding into other widgets. --- egui_commonmark/src/parsers/pulldown.rs | 3 ++- egui_commonmark_macros/src/generator.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/egui_commonmark/src/parsers/pulldown.rs b/egui_commonmark/src/parsers/pulldown.rs index 74ac831..7afc7a9 100644 --- a/egui_commonmark/src/parsers/pulldown.rs +++ b/egui_commonmark/src/parsers/pulldown.rs @@ -679,6 +679,7 @@ impl CommonMarkViewerInternal { pulldown_cmark::TagEnd::CodeBlock => { self.end_code_block(ui, cache, options, max_width); } + pulldown_cmark::TagEnd::List(_) => { self.line.should_start_newline = true; self.line.should_end_newline = true; @@ -740,8 +741,8 @@ impl CommonMarkViewerInternal { ) { if let Some(block) = self.fenced_code_block.take() { block.end(ui, cache, options, max_width); - self.text_style.code = false; self.line.try_insert_end(ui); } + self.text_style.code = false; } } diff --git a/egui_commonmark_macros/src/generator.rs b/egui_commonmark_macros/src/generator.rs index 534fc81..8d4e8ee 100644 --- a/egui_commonmark_macros/src/generator.rs +++ b/egui_commonmark_macros/src/generator.rs @@ -817,10 +817,11 @@ impl CommonMarkViewerInternal { .end(ui, #cache, &options, max_width); )); - self.text_style.code = false; stream.extend(self.line.try_insert_end()); } + self.text_style.code = false; + stream }