diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs
index 8f3c3320..e4c2faf4 100644
--- a/src/renderer/html_handlebars/hbs_renderer.rs
+++ b/src/renderer/html_handlebars/hbs_renderer.rs
@@ -496,8 +496,8 @@ fn make_data(
Ok(data)
}
-/// Goes through the rendered HTML, making sure all header tags are wrapped in
-/// an anchor so people can link to sections directly.
+/// Goes through the rendered HTML, making sure all header tags have
+/// an anchor respectively so people can link to sections directly.
fn build_header_links(html: &str) -> String {
let regex = Regex::new(r"(.*?)").unwrap();
let mut id_counter = HashMap::new();
@@ -508,14 +508,14 @@ fn build_header_links(html: &str) -> String {
.parse()
.expect("Regex should ensure we only ever get numbers here");
- wrap_header_with_link(level, &caps[2], &mut id_counter)
+ insert_link_into_header(level, &caps[2], &mut id_counter)
})
.into_owned()
}
-/// Wraps a single header tag with a link, making sure each tag gets its own
+/// Insert a sinle link into a header, making sure each link gets its own
/// unique ID by appending an auto-incremented number (if necessary).
-fn wrap_header_with_link(
+fn insert_link_into_header(
level: usize,
content: &str,
id_counter: &mut HashMap,
@@ -532,7 +532,7 @@ fn wrap_header_with_link(
*id_count += 1;
format!(
- r##""##,
+ r##""##,
level = level,
id = id,
text = content
@@ -640,27 +640,27 @@ mod tests {
let inputs = vec![
(
"blah blah Foo
",
- r##"blah blah "##,
+ r##"blah blah "##,
),
(
"Foo
",
- r##""##,
+ r##""##,
),
(
"Foo^bar
",
- r##""##,
+ r##""##,
),
(
"",
- r##""##,
+ r##""##,
),
(
"Hï
",
- r##""##,
+ r##""##,
),
(
"Foo
Foo
",
- r##""##,
+ r##""##,
),
];
diff --git a/src/theme/css/general.css b/src/theme/css/general.css
index f0aefa2a..57d5d7a6 100644
--- a/src/theme/css/general.css
+++ b/src/theme/css/general.css
@@ -34,10 +34,10 @@ h4, h5 { margin-top: 2em; }
margin-top: 1em;
}
-a.header:target h1:before,
-a.header:target h2:before,
-a.header:target h3:before,
-a.header:target h4:before {
+h1 a.header:target::before,
+h2 a.header:target::before,
+h3 a.header:target::before,
+h4 a.header:target::before {
display: inline-block;
content: "»";
margin-left: -30px;
diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs
index dfee1793..dd579903 100644
--- a/tests/rendered_output.rs
+++ b/tests/rendered_output.rs
@@ -327,7 +327,10 @@ fn able_to_include_files_in_chapters() {
let includes = temp.path().join("book/first/includes.html");
- let summary_strings = &["Summary
", ">First Chapter"];
+ let summary_strings = &[
+ r##""##,
+ ">First Chapter",
+ ];
assert_contains_strings(&includes, summary_strings);
assert_doesnt_contain_strings(&includes, &["{{#include ../SUMMARY.md::}}"]);