@@ -11,8 +11,7 @@ pub fn markdown(props: &Props) -> Html {
11
11
let link_regex = Regex :: new ( r"\[([^\]]+)\]\((https?://[^\)]+)\)" ) . unwrap ( ) ;
12
12
13
13
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
16
15
let mut line_html = vec ! [ ] ;
17
16
let mut last_pos = 0 ;
18
17
for chars in link_regex. captures_iter ( line) {
@@ -36,16 +35,15 @@ pub fn markdown(props: &Props) -> Html {
36
35
let combined_html = html ! { <>{ for line_html} </> } ;
37
36
38
37
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>} ,
43
42
l if l. starts_with ( "```" ) => {
44
43
html ! { <p><code lang="rust" >{ line. replace( "```" , "" ) } </code></p>}
45
44
}
46
45
l if l. starts_with ( "---" ) => html ! { <hr/>} ,
47
46
l if l. starts_with ( "___" ) => html ! { <hr/>} ,
48
- l if l. starts_with ( "-" ) => html ! { <li>{ & l[ 1 ..] } </li>} ,
49
47
l if l. is_empty ( ) => html ! { <br/>} ,
50
48
_ => html ! { <p>{ combined_html} </p>} ,
51
49
}
0 commit comments