forked from realaravinth/libmedium
fix: link formatting eating an extra character
This commit is contained in:
parent
6424c85b98
commit
ebb5d5175b
1 changed files with 31 additions and 30 deletions
|
@ -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" {.>
|
||||
<a rel="noreferrer" href="<.= markup.href.as_ref().unwrap() .>"><.= text .></a>
|
||||
<.} else if anchor_type == "USER" {.>
|
||||
<a
|
||||
rel="noreferrer"
|
||||
href="https://medium.com/u/<.= markup.user_id.as_ref().unwrap() .>"
|
||||
>
|
||||
<.= text .>
|
||||
</a>
|
||||
<.} else {.>
|
||||
<. log::error!("unknown markup.anchor_type: {:?} post id {}", anchor_type, id); .>
|
||||
<span><.= text .></span>
|
||||
<.}.>
|
||||
<.}.>
|
||||
<.} else if markup.type_ == "EM" {.>
|
||||
<em><.= text .></em>
|
||||
<.} else if markup.type_ == "STRONG" {.>
|
||||
<strong><.= text .></strong>
|
||||
<.} else if markup.type_ == "CODE" {.>
|
||||
<code><.= text .></code>
|
||||
<.} else {.>
|
||||
<. log::error!("unknown markup.type_: {:?} post id {}", markup.type_, id); .>
|
||||
<span><.= text .></span>
|
||||
<. 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" {.>
|
||||
<a rel="noreferrer" href="<.= markup.href.as_ref().unwrap() .>"><.= text .></a>
|
||||
<.} else if anchor_type == "USER" {.>
|
||||
<a
|
||||
rel="noreferrer"
|
||||
href="https://medium.com/u/<.= markup.user_id.as_ref().unwrap() .>"
|
||||
>
|
||||
<.= text .>
|
||||
</a>
|
||||
<.} else {.>
|
||||
<. log::error!("unknown markup.anchor_type: {:?} post id {}", anchor_type, id); .>
|
||||
<span><.= text .></span>
|
||||
<.}.>
|
||||
<.}.>
|
||||
<.} else if markup.type_ == "EM" {.>
|
||||
<em><.= text .></em>
|
||||
<.} else if markup.type_ == "STRONG" {.>
|
||||
<strong><.= text .></strong>
|
||||
<.} else if markup.type_ == "CODE" {.>
|
||||
<code><.= text .></code>
|
||||
<.} else {.>
|
||||
<. log::error!("unknown markup.type_: {:?} post id {}", markup.type_, id); .>
|
||||
<span><.= text .></span>
|
||||
<.}.>
|
||||
<.}.>
|
||||
<. if cur < p.text.len() {.>
|
||||
<.= p.text.slice(cur..) .>
|
||||
|
|
Loading…
Reference in a new issue