From d674edc7d0068680c0d6871e6b3e8badf4659096 Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 9 Mar 2026 16:53:42 +0200 Subject: [PATCH] remove extras --- .../browser/window/tab/item/page/content.rs | 27 +++---------------- .../window/tab/item/page/content/text.rs | 27 +++++-------------- .../tab/item/page/content/text/markdown.rs | 27 ++----------------- 3 files changed, 12 insertions(+), 69 deletions(-) diff --git a/src/app/browser/window/tab/item/page/content.rs b/src/app/browser/window/tab/item/page/content.rs index 05247888..fc88758d 100644 --- a/src/app/browser/window/tab/item/page/content.rs +++ b/src/app/browser/window/tab/item/page/content.rs @@ -157,30 +157,9 @@ impl Content { /// `text/markdown` pub fn to_text_markdown(&self, base: &Uri, data: &str) -> Text { self.clean(); - match Text::markdown((&self.window_action, &self.item_action), base, data) { - Ok(text) => { - self.g_box.append(&text.scrolled_window); - text - } - Err((message, text)) => { - self.g_box.append(&{ - let banner = adw::Banner::builder() - .title(message) - .revealed(true) - .button_label("Ok") - .build(); - banner.connect_button_clicked(|this| this.set_revealed(false)); - banner - }); - match text { - Some(text) => { - self.g_box.append(&text.scrolled_window); - text - } - None => todo!(), - } - } - } + let m = Text::markdown((&self.window_action, &self.item_action), base, data); + self.g_box.append(&m.scrolled_window); + m } /// `text/plain` diff --git a/src/app/browser/window/tab/item/page/content/text.rs b/src/app/browser/window/tab/item/page/content/text.rs index 53730409..9a634185 100644 --- a/src/app/browser/window/tab/item/page/content/text.rs +++ b/src/app/browser/window/tab/item/page/content/text.rs @@ -57,26 +57,13 @@ impl Text { actions: (&Rc, &Rc), base: &Uri, gemtext: &str, - ) -> Result)> { - match Markdown::build(actions, base, gemtext) { - Ok(widget) => Ok(Self { - scrolled_window: reader(&widget.text_view), - text_view: widget.text_view, - meta: Meta { - title: widget.title, - }, - }), - Err(e) => match e { - markdown::Error::Markup(message, widget) => Err(( - message, - Some(Self { - scrolled_window: reader(&widget.text_view), - text_view: widget.text_view, - meta: Meta { - title: widget.title, - }, - }), - )), + ) -> Self { + let markdown = Markdown::build(actions, base, gemtext); + Self { + scrolled_window: reader(&markdown.text_view), + text_view: markdown.text_view, + meta: Meta { + title: markdown.title, }, } } diff --git a/src/app/browser/window/tab/item/page/content/text/markdown.rs b/src/app/browser/window/tab/item/page/content/text/markdown.rs index b06c372c..fb15924b 100644 --- a/src/app/browser/window/tab/item/page/content/text/markdown.rs +++ b/src/app/browser/window/tab/item/page/content/text/markdown.rs @@ -34,7 +34,7 @@ impl Markdown { (window_action, item_action): (&Rc, &Rc), base: &Uri, markdown: &str, - ) -> Result { + ) -> Self { // Init HashMap storage (for event controllers) let mut links: HashMap = HashMap::new(); @@ -81,22 +81,7 @@ impl Markdown { // Init gutter widget (the tooltip on URL tags hover) let gutter = Gutter::build(&text_view); - // Disable code format on at least one closing tag not found - // gemini://bbs.geminispace.org/s/Gemini/26031 - let is_code_enabled = { - use ggemtext::line::code::{self}; - let mut t: usize = 0; - for l in markdown.lines() { - if l.starts_with(code::TAG) { - t += 1; - } - } - t == 0 || t.is_multiple_of(2) - }; - // Render markdown tags - // * keep in order! - let title = tags.render(&buffer, &base, &link_color.0, &mut links); // Parse single-line markdown tags @@ -418,15 +403,7 @@ impl Markdown { } }); // @TODO may be expensive for CPU, add timeout? - // Result - if is_code_enabled { - Ok(Self { text_view, title }) - } else { - Err(Error::Markup( - "Invalid multiline markup! Markdown format partially ignored.".to_string(), - Self { text_view, title }, - )) - } + Self { text_view, title } } }