diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs
index 5948e9ab..fe78c920 100644
--- a/src/renderer/html_handlebars/hbs_renderer.rs
+++ b/src/renderer/html_handlebars/hbs_renderer.rs
@@ -419,8 +419,7 @@ fn build_header_links(html: String, filename: &str) -> String {
id = id.replace(sub, "");
}
let id = id.chars()
- .filter(|c| if c.is_alphanumeric() || c == '-' || c == '_')
- .map(|c| {
+ .filter_map(|c| if c.is_alphanumeric() || c == '-' || c == '_' {
if c.is_ascii() {
Some(c.to_ascii_lowercase())
} else {
@@ -561,3 +560,27 @@ struct RenderItemContext<'a> {
data: serde_json::Map,
is_index: bool,
}
+
+
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn original_build_header_links() {
+ let inputs = vec![
+ ("blah blah Foo
", r#"blah blah "#),
+ ("Foo
", r#""#),
+ ("Foo^bar
", r#""#),
+ ("", r#""#),
+ ("Hï
", r#""#),
+ ("Foo
Foo
", r#""#),
+ ];
+
+ for (src, should_be) in inputs {
+ let got = build_header_links(src.to_string(), "bar.rs");
+ assert_eq!(got, should_be);
+ }
+ }
+}
\ No newline at end of file