From 68fa37d61babe8d990ace5f9cb5a7de81eb57ea0 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Sun, 16 Apr 2023 14:44:48 +0200 Subject: Add gemini parsing --- src/gemini_parser.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/gemini_parser.rs') diff --git a/src/gemini_parser.rs b/src/gemini_parser.rs index 36abb16..5c20426 100644 --- a/src/gemini_parser.rs +++ b/src/gemini_parser.rs @@ -7,7 +7,11 @@ pub fn parse(source: &str) -> String { let mut current_line_type: Option = None; for line in lines { - let line_type = identify_line(&(line[..3]), is_preformatted); + let mut line_type = LineType::Text; + if line.len() > 2 { + let end = line.char_indices().map(|(i, _)| i).nth(2).unwrap(); + line_type = identify_line(&(line[..end]), is_preformatted); + } match line_type { LineType::PreformattedToggle => is_preformatted = !is_preformatted, _ => { -- cgit