X-Git-Url: https://git.r.bdr.sh/rbdr/page/blobdiff_plain/68fa37d61babe8d990ace5f9cb5a7de81eb57ea0..7348f5ea3a1182c9f4a75d05a405e90f9e33797c:/src/gemini_parser.rs?ds=inline diff --git a/src/gemini_parser.rs b/src/gemini_parser.rs index 5c20426..d0715f1 100644 --- a/src/gemini_parser.rs +++ b/src/gemini_parser.rs @@ -8,9 +8,12 @@ pub fn parse(source: &str) -> String { for line in lines { 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); + if line.char_indices().count() > 2 { + let mut end = line.len(); + if line.char_indices().count() > 3 { + end = line.char_indices().map(|(i, _)| i).nth(3).unwrap(); + } + line_type = identify_line(&line[..end], is_preformatted); } match line_type { LineType::PreformattedToggle => is_preformatted = !is_preformatted, @@ -72,7 +75,14 @@ fn get_full_line_content(line_type: &LineType, line: &str) -> String { match line_type { LineType::Text => format!("
{}
\n", line.trim()), LineType::Blank => "