@@ -289,6 +289,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
289
289
// html for text rather than the raw text.
290
290
let mut id = s. clone ( ) ;
291
291
let repl_sub = vec ! [ "<em>" , "</em>" , "<code>" , "</code>" ,
292
+ "<strong>" , "</strong>" ,
292
293
"<" , ">" , "&" , "'" , """ ] ;
293
294
for sub in repl_sub {
294
295
id = id. replace ( sub, "" ) ;
@@ -326,8 +327,8 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
326
327
} ) ;
327
328
328
329
// Render the HTML
329
- let text = format ! ( r## "<h{lvl} id=" {id}" class='section-header'><a
330
- href=" #{id}" >{sec}{}</a></h{lvl}>"## ,
330
+ let text = format ! ( "<h{lvl} id=' {id}' class='section-header'>\
331
+ <a href=' #{id}' >{sec}{}</a></h{lvl}>",
331
332
s, lvl = level, id = id, sec = sec) ;
332
333
333
334
let text = CString :: new ( text) . unwrap ( ) ;
@@ -612,6 +613,27 @@ mod tests {
612
613
format ! ( "{}" , Markdown ( markdown) ) ;
613
614
}
614
615
616
+ #[ test]
617
+ fn test_header ( ) {
618
+ fn t ( input : & str , expect : & str ) {
619
+ let output = format ! ( "{}" , Markdown ( input) ) ;
620
+ assert_eq ! ( output, expect) ;
621
+ }
622
+
623
+ t ( "# Foo bar" , "\n <h1 id='foo-bar' class='section-header'>\
624
+ <a href='#foo-bar'>Foo bar</a></h1>") ;
625
+ t ( "## Foo-bar_baz qux" , "\n <h2 id='foo-bar_baz-qux' class=\' section-\
626
+ header'><a href='#foo-bar_baz-qux'>Foo-bar_baz qux</a></h2>") ;
627
+ t ( "### **Foo** *bar* baz!?!& -_qux_-%" ,
628
+ "\n <h3 id='foo-bar-baz--_qux_-' class='section-header'>\
629
+ <a href='#foo-bar-baz--_qux_-'><strong>Foo</strong> \
630
+ <em>bar</em> baz!?!& -_qux_-%</a></h3>") ;
631
+ t ( "####**Foo?** & \\ *bar?!* _`baz`_ ❤ #qux" ,
632
+ "\n <h4 id='foo--bar--baz--qux' class='section-header'>\
633
+ <a href='#foo--bar--baz--qux'><strong>Foo?</strong> & *bar?!* \
634
+ <em><code>baz</code></em> ❤ #qux</a></h4>") ;
635
+ }
636
+
615
637
#[ test]
616
638
fn test_plain_summary_line ( ) {
617
639
fn t ( input : & str , expect : & str ) {
0 commit comments