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

Format code using cargo fmt #896

Merged
merged 1 commit into from
Dec 23, 2019
Merged
Show file tree
Hide file tree
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
4 changes: 1 addition & 3 deletions components/front_matter/src/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ impl PageFrontMatter {
if d.contains('T') {
DateTime::parse_from_rfc3339(&d).ok().map(|s| s.naive_local())
} else {
NaiveDate::parse_from_str(&d, "%Y-%m-%d")
.ok()
.map(|s| s.and_hms(0, 0, 0))
NaiveDate::parse_from_str(&d, "%Y-%m-%d").ok().map(|s| s.and_hms(0, 0, 0))
}
} else {
None
Expand Down
5 changes: 4 additions & 1 deletion components/library/src/content/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ impl Page {
if let Some(slug) = slug_from_dated_filename {
maybe_slugify_paths(&slug, config.slugify_paths)
} else {
maybe_slugify_paths(parent.file_name().unwrap().to_str().unwrap(), config.slugify_paths)
maybe_slugify_paths(
parent.file_name().unwrap().to_str().unwrap(),
config.slugify_paths,
)
}
} else {
maybe_slugify_paths(&page.file.name, config.slugify_paths)
Expand Down
6 changes: 1 addition & 5 deletions components/library/src/pagination/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,7 @@ impl<'a> Paginator<'a> {
} else {
format!("{}{}/", self.permalink, self.paginate_path)
};
paginator.insert(
"base_url",
to_value(&base_url).unwrap(),
);
paginator.insert("base_url", to_value(&base_url).unwrap());
paginator.insert("pages", to_value(&current_pager.pages).unwrap());
paginator.insert("current_index", to_value(current_pager.index).unwrap());
paginator.insert("total_pages", to_value(self.all_pages.len()).unwrap());
Expand Down Expand Up @@ -384,7 +381,6 @@ mod tests {
assert_eq!(paginator.pagers[1].permalink, "https://vincent.is/posts/2/");
assert_eq!(paginator.pagers[1].path, "posts/2/");


let context = paginator.build_paginator_context(&paginator.pagers[0]);
assert_eq!(context["base_url"], to_value("https://vincent.is/posts/").unwrap());
}
Expand Down
6 changes: 1 addition & 5 deletions components/library/src/taxonomies/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,7 @@ mod tests {

assert_eq!(categories.items.len(), 1);
assert_eq!(categories.items[0].name, "Écologie");
assert_eq!(
categories.items[0].permalink,
"http://a-website.com/fr/catégories/Écologie/"
);
assert_eq!(categories.items[0].permalink, "http://a-website.com/fr/catégories/Écologie/");
assert_eq!(categories.items[0].pages.len(), 1);
}

Expand Down Expand Up @@ -711,5 +708,4 @@ mod tests {
);
assert_eq!(categories.items[1].pages.len(), 1);
}

}
12 changes: 8 additions & 4 deletions components/rendering/src/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use config::highlighting::{get_highlighter, SYNTAX_SET, THEME_SET};
use errors::{Error, Result};
use front_matter::InsertAnchor;
use utils::site::resolve_internal_link;
use utils::vec::InsertMany;
use utils::slugs::maybe_slugify_anchors;
use utils::vec::InsertMany;

use self::cmark::{Event, LinkType, Options, Parser, Tag};

Expand Down Expand Up @@ -297,9 +297,13 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result<Render
let start_idx = heading_ref.start_idx;
let end_idx = heading_ref.end_idx;
let title = get_text(&events[start_idx + 1..end_idx]);
let id = heading_ref
.id
.unwrap_or_else(|| find_anchor(&inserted_anchors, maybe_slugify_anchors(&title, context.config.slugify_paths), 0));
let id = heading_ref.id.unwrap_or_else(|| {
find_anchor(
&inserted_anchors,
maybe_slugify_anchors(&title, context.config.slugify_paths),
0,
)
});
inserted_anchors.push(id.clone());

// insert `id` to the tag
Expand Down
2 changes: 1 addition & 1 deletion components/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ pub mod de;
pub mod fs;
pub mod net;
pub mod site;
pub mod slugs;
pub mod templates;
pub mod vec;
pub mod slugs;
8 changes: 3 additions & 5 deletions components/utils/src/slugs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn strip_chars(s: &str, chars: &str) -> String {
let mut sanitized_string = s.to_string();
sanitized_string.retain( |c| !chars.contains(c));
sanitized_string.retain(|c| !chars.contains(c));
sanitized_string
}

Expand All @@ -24,8 +24,7 @@ pub fn maybe_slugify_paths(s: &str, slugify: bool) -> String {
if slugify {
// ASCII slugification
slug::slugify(s)
}
else {
} else {
// Only remove forbidden characters
strip_invalid_paths_chars(s)
}
Expand All @@ -35,8 +34,7 @@ pub fn maybe_slugify_anchors(s: &str, slugify: bool) -> String {
if slugify {
// ASCII slugification
slug::slugify(s)
}
else {
} else {
// Only remove forbidden characters
strip_invalid_anchors_chars(s)
}
Expand Down