aboutsummaryrefslogtreecommitdiff
path: root/src/gemini_parser.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/gemini_parser.rs')
-rw-r--r--src/gemini_parser.rs6
1 files changed, 5 insertions, 1 deletions
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<LineType> = 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,
_ => {