X-Git-Url: https://git.r.bdr.sh/rbdr/page/blobdiff_plain/4cbe65303a0e5d6060c3b608fb69181feda8b8d3..68fa37d61babe8d990ace5f9cb5a7de81eb57ea0:/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, _ => {