Skip to content

Commit f83580a

Browse files
authored
Merge pull request #262 from AndrewCS149/markdownFix
fix
2 parents e91e3c2 + 1e5d114 commit f83580a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

client/src/components/markdown.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ pub fn markdown(props: &Props) -> Html {
1111
let link_regex = Regex::new(r"\[([^\]]+)\]\((https?://[^\)]+)\)").unwrap();
1212

1313
let html = props.content.lines().map(|line| {
14-
// replace markdown links with anchor tags
15-
// eg: [thedevblog](https://thedevblog.net) -> <a href="https://thedevblog.net">thedevblog</a>
14+
// Process links for the entire line
1615
let mut line_html = vec![];
1716
let mut last_pos = 0;
1817
for chars in link_regex.captures_iter(line) {
@@ -36,16 +35,15 @@ pub fn markdown(props: &Props) -> Html {
3635
let combined_html = html! { <>{for line_html}</> };
3736

3837
match line {
39-
l if l.starts_with("# ") => html! {<h1>{&l[1..]}</h1>},
40-
l if l.starts_with("## ") => html! {<h2>{&l[2..]}</h2>},
41-
l if l.starts_with("### ") => html! {<h3>{&l[3..]}</h3>},
42-
l if l.starts_with("#### ") => html! {<h4>{&l[4..]}</h4>},
38+
l if l.starts_with("# ") => html! {<h1>{combined_html}</h1>},
39+
l if l.starts_with("## ") => html! {<h2>{combined_html}</h2>},
40+
l if l.starts_with("### ") => html! {<h3>{combined_html}</h3>},
41+
l if l.starts_with("#### ") => html! {<h4>{combined_html}</h4>},
4342
l if l.starts_with("```") => {
4443
html! {<p><code lang="rust">{line.replace("```", "")}</code></p>}
4544
}
4645
l if l.starts_with("---") => html! {<hr/>},
4746
l if l.starts_with("___") => html! {<hr/>},
48-
l if l.starts_with("-") => html! {<li>{&l[1..]}</li>},
4947
l if l.is_empty() => html! {<br/>},
5048
_ => html! {<p>{combined_html}</p>},
5149
}

0 commit comments

Comments
 (0)