Replace trim_{left, right} with trim_{start, end}

trim_{start, end} is introduced in rust 1.30.0 and
trim_{left, right} is deprecated since 1.33.0.
This commit is contained in:
Peng Guanwen 2019-01-29 16:30:54 +08:00
parent 9398ab789c
commit 0b897ce7c7
4 changed files with 5 additions and 5 deletions

View File

@ -153,7 +153,7 @@ impl Page {
};
if let Some(ref p) = page.meta.path {
page.path = p.trim().trim_left_matches('/').to_string();
page.path = p.trim().trim_start_matches('/').to_string();
} else {
let mut path = if page.file.components.is_empty() {
page.slug.clone()

View File

@ -108,7 +108,7 @@ fn render_shortcode(
}
if let Some(ref b) = body {
// Trimming right to avoid most shortcodes with bodies ending up with a HTML new line
tera_context.insert("body", b.trim_right());
tera_context.insert("body", b.trim_end());
}
tera_context.extend(context.tera_context.clone());

View File

@ -21,9 +21,9 @@ pub fn markdown(value: &Value, args: &HashMap<String, Value>) -> TeraResult<Valu
if inline {
html = html
.trim_left_matches("<p>")
.trim_start_matches("<p>")
// pulldown_cmark finishes a paragraph with `</p>\n`
.trim_right_matches("</p>\n")
.trim_end_matches("</p>\n")
.to_string();
}

View File

@ -41,7 +41,7 @@ pub fn create_new_project(name: &str) -> Result<()> {
let search = ask_bool("> Do you want to build a search index of the content?", false)?;
let config = CONFIG
.trim_left()
.trim_start()
.replace("%BASE_URL%", &base_url)
.replace("%COMPILE_SASS%", &format!("{}", compile_sass))
.replace("%SEARCH%", &format!("{}", search))