From 260dcb97e1896c5e6b29b276830f75518464f3de Mon Sep 17 00:00:00 2001 From: realaravinth Date: Tue, 2 Nov 2021 11:59:13 +0530 Subject: [PATCH] fix repetition bug when text contained markup data, unprocessed string was being printed before all the markup had been processed. This caused a repetition bug. --- templates/p.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/templates/p.html b/templates/p.html index 44e8f41..f65b198 100644 --- a/templates/p.html +++ b/templates/p.html @@ -6,7 +6,8 @@ <. for markup in &p.markups {.> <.= &p.text.substring(cur, (markup.start -1) as usize) .> <. cur = (markup.end + 1) as usize; .> - <. let text = &p.text.substring(markup.start as usize, markup.end as usize); .> + <. let text = &p.text.slice(markup.start as usize..markup.end as usize); .> + <. println!("{}", text); .> <. if markup.type_ == "A" {.> <. if let Some(anchor_type) = &markup.anchor_type {.> <. if anchor_type == "LINK" {.> @@ -33,10 +34,10 @@ <. log::error!("unknown markup.type_: {:?} post id {}", markup.type_, id); .> <.= text .> <.}.> + <.}.> - <. if cur < p.text.len() {.> - <.= p.text.slice(cur..) .> - <.}.> + <. if cur < p.text.len() {.> + <.= p.text.slice(cur..) .> <.}.> <.}.>