Wrap draft chapter titles in a <div>

Fixes the problem of a missing space before the title of draft chapters,
due to the title not being wrapped in an `<a></a>`.
This commit is contained in:
Søren Mortensen 2020-08-31 10:00:03 +01:00
parent f6768b816c
commit 2fb489137b
No known key found for this signature in database
GPG Key ID: 80F62AC681D451B6
1 changed files with 23 additions and 21 deletions

View File

@ -108,32 +108,32 @@ impl HelperDef for RenderToc {
} }
// Link // Link
let path_exists = if let Some(path) = item.get("path") { let path_exists = if let Some(path) =
if !path.is_empty() { item.get("path")
out.write("<a href=\"")?; .and_then(|p| if p.is_empty() { None } else { Some(p) })
{
out.write("<a href=\"")?;
let tmp = Path::new(item.get("path").expect("Error: path should be Some(_)")) let tmp = Path::new(item.get("path").expect("Error: path should be Some(_)"))
.with_extension("html") .with_extension("html")
.to_str() .to_str()
.unwrap() .unwrap()
// Hack for windows who tends to use `\` as separator instead of `/` // Hack for windows who tends to use `\` as separator instead of `/`
.replace("\\", "/"); .replace("\\", "/");
// Add link // Add link
out.write(&utils::fs::path_to_root(&current_path))?; out.write(&utils::fs::path_to_root(&current_path))?;
out.write(&tmp)?; out.write(&tmp)?;
out.write("\"")?; out.write("\"")?;
if path == &current_path { if path == &current_path {
out.write(" class=\"active\"")?; out.write(" class=\"active\"")?;
}
out.write(">")?;
true
} else {
false
} }
out.write(">")?;
true
} else { } else {
out.write("<div>")?;
false false
}; };
@ -165,6 +165,8 @@ impl HelperDef for RenderToc {
if path_exists { if path_exists {
out.write("</a>")?; out.write("</a>")?;
} else {
out.write("</div>")?;
} }
// Render expand/collapse toggle // Render expand/collapse toggle