From 54e370215b05e767feb0150704877a21ebd2c1f4 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 12 Oct 2024 11:24:43 +0300 Subject: [PATCH] drop deprecated constructions --- .../item/page/content/text/gemini/reader.rs | 11 +++++------ .../page/content/text/gemini/reader/parser.rs | 1 - .../text/gemini/reader/parser/plain.rs | 19 ------------------- 3 files changed, 5 insertions(+), 26 deletions(-) delete mode 100644 src/app/browser/window/tab/item/page/content/text/gemini/reader/parser/plain.rs diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/reader.rs b/src/app/browser/window/tab/item/page/content/text/gemini/reader.rs index 4dbc0766..23062ff4 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini/reader.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini/reader.rs @@ -3,7 +3,6 @@ mod widget; use parser::header::Header; use parser::link::Link; -use parser::plain::Plain; use widget::Widget; use gtk::{ @@ -30,12 +29,13 @@ impl Reader { // Init markup let buffer = TextBuffer::new(None); + // Parse lines for line in gemtext.lines() { /* // Is header if let Some(header) = Header::from(line) { // Format - markup.push_str(header.markup()); + buffer.insert_markup(&mut buffer.end_iter(), header.markup()); // Set title from first document header tag if title == None { @@ -48,16 +48,15 @@ impl Reader { // Is link if let Some(link) = Link::from(line, base) { // Format - markup.push_str(link.markup()); + buffer.insert_markup(&mut buffer.end_iter(), link.markup()); continue; } // Nothing match, escape string just - markup.push_str(Plain::from(line).markup()) - */ + buffer.insert_markup(&mut buffer.end_iter(), Plain::from(line).markup()) */ - buffer.insert(&mut buffer.end_iter(), Plain::from(line).as_str()); + buffer.insert(&mut buffer.end_iter(), format!("{line}\n").as_str()) // @TODO } // Init widget diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/reader/parser.rs b/src/app/browser/window/tab/item/page/content/text/gemini/reader/parser.rs index 9d77b73d..d3477c7b 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini/reader/parser.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini/reader/parser.rs @@ -1,3 +1,2 @@ pub mod header; pub mod link; -pub mod plain; diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/reader/parser/plain.rs b/src/app/browser/window/tab/item/page/content/text/gemini/reader/parser/plain.rs deleted file mode 100644 index 0bde3823..00000000 --- a/src/app/browser/window/tab/item/page/content/text/gemini/reader/parser/plain.rs +++ /dev/null @@ -1,19 +0,0 @@ -use gtk::glib::{gformat, GString}; - -pub struct Plain { - line: GString, -} - -impl Plain { - // Construct - pub fn from(line: &str) -> Self { - Self { - line: gformat!("{}\n", line), - } - } - - // Getters - pub fn as_str(&self) -> &str { - self.line.as_str() - } -}