Skip to content

Commit c8a5adc

Browse files
ImUrXehuss
authored andcommitted
fix more mistakes
1 parent ecdb411 commit c8a5adc

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/renderer/html_handlebars/hbs_renderer.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ fn build_header_links(html: &str) -> String {
792792
static BUILD_HEADER_LINKS: Lazy<Regex> = Lazy::new(|| {
793793
Regex::new(r#"<h(\d)(?: id="([^"]+)")?(?: class="([^"]+)")?>(.*?)</h\d>"#).unwrap()
794794
});
795-
static IGNORE_CLASS: &'static [&str] = &["menu-title"];
795+
static IGNORE_CLASS: &[&str] = &["menu-title"];
796796

797797
let mut id_counter = HashMap::new();
798798

@@ -835,7 +835,7 @@ fn insert_link_into_header(
835835
let classes = classes.unwrap_or("".to_string());
836836

837837
format!(
838-
r##"<h{level} id="{id}" classes="{classes}"><a class="header" href="#{id}">{text}</a></h{level}>"##,
838+
r##"<h{level} id="{id}" class="{classes}"><a class="header" href="#{id}">{text}</a></h{level}>"##,
839839
level = level,
840840
id = id,
841841
text = content,
@@ -1014,27 +1014,31 @@ mod tests {
10141014
let inputs = vec![
10151015
(
10161016
"blah blah <h1>Foo</h1>",
1017-
r##"blah blah <h1 id="foo"><a class="header" href="#foo">Foo</a></h1>"##,
1017+
r##"blah blah <h1 id="foo" class=""><a class="header" href="#foo">Foo</a></h1>"##,
10181018
),
10191019
(
10201020
"<h1>Foo</h1>",
1021-
r##"<h1 id="foo"><a class="header" href="#foo">Foo</a></h1>"##,
1021+
r##"<h1 id="foo" class=""><a class="header" href="#foo">Foo</a></h1>"##,
10221022
),
10231023
(
10241024
"<h3>Foo^bar</h3>",
1025-
r##"<h3 id="foobar"><a class="header" href="#foobar">Foo^bar</a></h3>"##,
1025+
r##"<h3 id="foobar" class=""><a class="header" href="#foobar">Foo^bar</a></h3>"##,
10261026
),
10271027
(
10281028
"<h4></h4>",
1029-
r##"<h4 id=""><a class="header" href="#"></a></h4>"##,
1029+
r##"<h4 id="" class=""><a class="header" href="#"></a></h4>"##,
10301030
),
10311031
(
10321032
"<h4><em>Hï</em></h4>",
1033-
r##"<h4 id="hï"><a class="header" href="#hï"><em>Hï</em></a></h4>"##,
1033+
r##"<h4 id="hï" class=""><a class="header" href="#hï"><em>Hï</em></a></h4>"##,
10341034
),
10351035
(
10361036
"<h1>Foo</h1><h3>Foo</h3>",
1037-
r##"<h1 id="foo"><a class="header" href="#foo">Foo</a></h1><h3 id="foo-1"><a class="header" href="#foo-1">Foo</a></h3>"##,
1037+
r##"<h1 id="foo" class=""><a class="header" href="#foo">Foo</a></h1><h3 id="foo-1" class=""><a class="header" href="#foo-1">Foo</a></h3>"##,
1038+
),
1039+
(
1040+
r##"<h1 id="foobar" class="class1 class2">Foo</h1>"##,
1041+
r##"<h1 id="foobar" class="class1 class2"><a class="header" href="#foobar">Foo</a></h1>"##,
10381042
),
10391043
];
10401044

tests/rendered_output.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ fn check_correct_cross_links_in_nested_dir() {
105105

106106
assert_contains_strings(
107107
first.join("index.html"),
108-
&[r##"<h2 id="some-section"><a class="header" href="#some-section">"##],
108+
&[r##"<h2 id="some-section" class=""><a class="header" href="#some-section">"##],
109109
);
110110

111111
assert_contains_strings(
112112
first.join("nested.html"),
113-
&[r##"<h2 id="some-section"><a class="header" href="#some-section">"##],
113+
&[r##"<h2 id="some-section" class=""><a class="header" href="#some-section">"##],
114114
);
115115
}
116116

@@ -393,7 +393,7 @@ fn able_to_include_files_in_chapters() {
393393
let includes = temp.path().join("book/first/includes.html");
394394

395395
let summary_strings = &[
396-
r##"<h1 id="summary"><a class="header" href="#summary">Summary</a></h1>"##,
396+
r##"<h1 id="summary" class=""><a class="header" href="#summary">Summary</a></h1>"##,
397397
">First Chapter</a>",
398398
];
399399
assert_contains_strings(&includes, summary_strings);

0 commit comments

Comments
 (0)