Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing space before draft chapter titles #1309

Merged
merged 1 commit into from
Sep 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 26 additions & 24 deletions src/renderer/html_handlebars/helpers/toc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&current_path))?;
out.write(&tmp)?;
out.write("\"")?;

if path == &current_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(&current_path))?;
out.write(&tmp)?;
out.write("\"")?;

if path == &current_path {
out.write(" class=\"active\"")?;
}

out.write(">")?;
true
} else {
out.write("<div>")?;
false
};

Expand Down Expand Up @@ -165,6 +165,8 @@ impl HelperDef for RenderToc {

if path_exists {
out.write("</a>")?;
} else {
out.write("</div>")?;
}

// Render expand/collapse toggle
Expand Down