From e4c62ca3b342efef229117a270f746bf3c85da94 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 10 Mar 2026 21:22:42 +0200 Subject: [PATCH] cleanup unformatted escape chars --- .../tab/item/page/content/text/markdown/tags.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app/browser/window/tab/item/page/content/text/markdown/tags.rs b/src/app/browser/window/tab/item/page/content/text/markdown/tags.rs index cd25684c..0644bbfe 100644 --- a/src/app/browser/window/tab/item/page/content/text/markdown/tags.rs +++ b/src/app/browser/window/tab/item/page/content/text/markdown/tags.rs @@ -10,7 +10,7 @@ mod underline; use bold::Bold; use code::Code; -use gtk::{TextBuffer, TextTag, gdk::RGBA, glib::Uri}; +use gtk::{TextBuffer, TextSearchFlags, TextTag, gdk::RGBA, glib::Uri, prelude::TextBufferExt}; use header::Header; use pre::Pre; use quote::Quote; @@ -54,7 +54,8 @@ impl Tags { link_color: &RGBA, links: &mut HashMap, ) -> Option { - // Collect all code blocks first, and replace them with tmp macro ID + // Collect all code blocks first, + // and temporarily replace them with placeholder ID self.code.collect(buffer); // Keep in order! @@ -73,6 +74,16 @@ impl Tags { reference::render_images(buffer, base, link_color, links); reference::render_links(buffer, base, link_color, links); + // Cleanup unformatted escape chars + let mut cursor = buffer.start_iter(); + while let Some((mut match_start, mut match_end)) = + cursor.forward_search("\\", TextSearchFlags::CASE_INSENSITIVE, None) + { + buffer.delete(&mut match_start, &mut match_end); + cursor = match_end; + } + + // Render placeholders self.code.render(buffer); // Format document title string