From ebb5d5175b337ac42c0b39bd1cc8d4d6859e7d1b Mon Sep 17 00:00:00 2001 From: realaravinth Date: Wed, 5 Jan 2022 11:17:08 +0530 Subject: [PATCH] fix: link formatting eating an extra character --- templates/p.html | 61 ++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/templates/p.html b/templates/p.html index 77d0851..a1dcee6 100644 --- a/templates/p.html +++ b/templates/p.html @@ -4,37 +4,38 @@ <.} else {.> <. let mut cur: usize = 0; .> <. for markup in &p.markups {.> - <. if markup.start != 0 {.> - <.= &p.text.substring(cur, (markup.start -1) as usize) .> - <.}.> - <. cur = (markup.end + 1) as usize; .> - <. let text = &p.text.slice(markup.start as usize..markup.end as usize); .> - <. if markup.type_ == "A" {.> - <. if let Some(anchor_type) = &markup.anchor_type {.> - <. if anchor_type == "LINK" {.> - <.= text .> - <.} else if anchor_type == "USER" {.> - - <.= text .> - - <.} else {.> - <. log::error!("unknown markup.anchor_type: {:?} post id {}", anchor_type, id); .> - <.= text .> - <.}.> - <.}.> - <.} else if markup.type_ == "EM" {.> - <.= text .> - <.} else if markup.type_ == "STRONG" {.> - <.= text .> - <.} else if markup.type_ == "CODE" {.> - <.= text .> - <.} else {.> - <. log::error!("unknown markup.type_: {:?} post id {}", markup.type_, id); .> - <.= text .> + <. if markup.start != 0 {.> + <.= &p.text.substring(cur, (markup.start -1) as usize) .> <.}.> + <. cur = (markup.end) as usize; .> + <. let text = &p.text.slice(markup.start as usize..markup.end as usize); .> + + <. if markup.type_ == "A" {.> + <. if let Some(anchor_type) = &markup.anchor_type {.> + <. if anchor_type == "LINK" {.> + <.= text .> + <.} else if anchor_type == "USER" {.> + + <.= text .> + + <.} else {.> + <. log::error!("unknown markup.anchor_type: {:?} post id {}", anchor_type, id); .> + <.= text .> + <.}.> + <.}.> + <.} else if markup.type_ == "EM" {.> + <.= text .> + <.} else if markup.type_ == "STRONG" {.> + <.= text .> + <.} else if markup.type_ == "CODE" {.> + <.= text .> + <.} else {.> + <. log::error!("unknown markup.type_: {:?} post id {}", markup.type_, id); .> + <.= text .> + <.}.> <.}.> <. if cur < p.text.len() {.> <.= p.text.slice(cur..) .>