diff options
author | Eric Huss <eric@huss.org> | 2020-09-06 09:40:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-06 09:40:55 -0700 |
commit | 4b773024ae9872c80b7e866e03472b08523e33b3 (patch) | |
tree | 775ebd44748393512a773b3511d5f081ebf1249e /src | |
parent | 33ea6613509ef1db6a45cf686217c69f7b047bd5 (diff) | |
parent | 2fb489137bc6769be5b3ab195937c5d00f51357e (diff) |
Merge pull request #1309 from nerosnm/add-missing-space
Fix missing space before draft chapter titles
Diffstat (limited to 'src')
-rw-r--r-- | src/renderer/html_handlebars/helpers/toc.rs | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/src/renderer/html_handlebars/helpers/toc.rs b/src/renderer/html_handlebars/helpers/toc.rs index 47eda596..7a5d8a28 100644 --- a/src/renderer/html_handlebars/helpers/toc.rs +++ b/src/renderer/html_handlebars/helpers/toc.rs @@ -108,32 +108,32 @@ impl HelperDef for RenderToc { } // Link - let path_exists = if let Some(path) = item.get("path") { - if !path.is_empty() { - out.write("<a href=\"")?; - - let tmp = Path::new(item.get("path").expect("Error: path should be Some(_)")) - .with_extension("html") - .to_str() - .unwrap() - // Hack for windows who tends to use `\` as separator instead of `/` - .replace("\\", "/"); - - // Add link - out.write(&utils::fs::path_to_root(¤t_path))?; - out.write(&tmp)?; - out.write("\"")?; - - if path == ¤t_path { - out.write(" class=\"active\"")?; - } - - out.write(">")?; - true - } else { - false + let path_exists = if let Some(path) = + item.get("path") + .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(_)")) + .with_extension("html") + .to_str() + .unwrap() + // Hack for windows who tends to use `\` as separator instead of `/` + .replace("\\", "/"); + + // Add link + out.write(&utils::fs::path_to_root(¤t_path))?; + out.write(&tmp)?; + out.write("\"")?; + + if path == ¤t_path { + out.write(" class=\"active\"")?; } + + out.write(">")?; + true } else { + out.write("<div>")?; false }; @@ -165,6 +165,8 @@ impl HelperDef for RenderToc { if path_exists { out.write("</a>")?; + } else { + out.write("</div>")?; } // Render expand/collapse toggle |