Skip to content

Commit 4b77302

Browse files
authored
Merge pull request #1309 from nerosnm/add-missing-space
Fix missing space before draft chapter titles
2 parents 33ea661 + 2fb4891 commit 4b77302

File tree

1 file changed

+26
-24
lines changed
  • src/renderer/html_handlebars/helpers

1 file changed

+26
-24
lines changed

src/renderer/html_handlebars/helpers/toc.rs

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -108,32 +108,32 @@ impl HelperDef for RenderToc {
108108
}
109109

110110
// Link
111-
let path_exists = if let Some(path) = item.get("path") {
112-
if !path.is_empty() {
113-
out.write("<a href=\"")?;
114-
115-
let tmp = Path::new(item.get("path").expect("Error: path should be Some(_)"))
116-
.with_extension("html")
117-
.to_str()
118-
.unwrap()
119-
// Hack for windows who tends to use `\` as separator instead of `/`
120-
.replace("\\", "/");
121-
122-
// Add link
123-
out.write(&utils::fs::path_to_root(&current_path))?;
124-
out.write(&tmp)?;
125-
out.write("\"")?;
126-
127-
if path == &current_path {
128-
out.write(" class=\"active\"")?;
129-
}
130-
131-
out.write(">")?;
132-
true
133-
} else {
134-
false
111+
let path_exists = if let Some(path) =
112+
item.get("path")
113+
.and_then(|p| if p.is_empty() { None } else { Some(p) })
114+
{
115+
out.write("<a href=\"")?;
116+
117+
let tmp = Path::new(item.get("path").expect("Error: path should be Some(_)"))
118+
.with_extension("html")
119+
.to_str()
120+
.unwrap()
121+
// Hack for windows who tends to use `\` as separator instead of `/`
122+
.replace("\\", "/");
123+
124+
// Add link
125+
out.write(&utils::fs::path_to_root(&current_path))?;
126+
out.write(&tmp)?;
127+
out.write("\"")?;
128+
129+
if path == &current_path {
130+
out.write(" class=\"active\"")?;
135131
}
132+
133+
out.write(">")?;
134+
true
136135
} else {
136+
out.write("<div>")?;
137137
false
138138
};
139139

@@ -165,6 +165,8 @@ impl HelperDef for RenderToc {
165165

166166
if path_exists {
167167
out.write("</a>")?;
168+
} else {
169+
out.write("</div>")?;
168170
}
169171

170172
// Render expand/collapse toggle

0 commit comments

Comments
 (0)