Skip to content

Commit 5d79606

Browse files
committed
---
yaml --- r: 234762 b: refs/heads/tmp c: 09c1ce1 h: refs/heads/master v: v3
1 parent 5d02be1 commit 5d79606

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: d2e13e822a73e0ea46ae9e21afdd3155fc997f6d
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: d6f0a21e207612b0064fdd93f2ae9338f839f1f7
28+
refs/heads/tmp: 09c1ce18a2711627da621b423d3291d01bc12c85
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: ab792abf1fcc28afbd315426213f6428da25c085
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/src/librustdoc/html/markdown.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
289289
// html for text rather than the raw text.
290290
let mut id = s.clone();
291291
let repl_sub = vec!["<em>", "</em>", "<code>", "</code>",
292+
"<strong>", "</strong>",
292293
"&lt;", "&gt;", "&amp;", "&#39;", "&quot;"];
293294
for sub in repl_sub {
294295
id = id.replace(sub, "");
@@ -326,8 +327,8 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
326327
});
327328

328329
// 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}>",
331332
s, lvl = level, id = id, sec = sec);
332333

333334
let text = CString::new(text).unwrap();
@@ -612,6 +613,27 @@ mod tests {
612613
format!("{}", Markdown(markdown));
613614
}
614615

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!?!&amp; -_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> &amp; *bar?!* \
634+
<em><code>baz</code></em> ❤ #qux</a></h4>");
635+
}
636+
615637
#[test]
616638
fn test_plain_summary_line() {
617639
fn t(input: &str, expect: &str) {

0 commit comments

Comments
 (0)