Browse Source

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.
index-subcmd
Peng Guanwen 5 years ago
parent
commit
0b897ce7c7
4 changed files with 5 additions and 5 deletions
  1. +1
    -1
      components/library/src/content/page.rs
  2. +1
    -1
      components/rendering/src/shortcode.rs
  3. +2
    -2
      components/templates/src/filters.rs
  4. +1
    -1
      src/cmd/init.rs

+ 1
- 1
components/library/src/content/page.rs View File

@@ -153,7 +153,7 @@ impl Page {
}; };


if let Some(ref p) = page.meta.path { 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 { } else {
let mut path = if page.file.components.is_empty() { let mut path = if page.file.components.is_empty() {
page.slug.clone() page.slug.clone()


+ 1
- 1
components/rendering/src/shortcode.rs View File

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




+ 2
- 2
components/templates/src/filters.rs View File

@@ -21,9 +21,9 @@ pub fn markdown(value: &Value, args: &HashMap<String, Value>) -> TeraResult<Valu


if inline { if inline {
html = html html = html
.trim_left_matches("<p>")
.trim_start_matches("<p>")
// pulldown_cmark finishes a paragraph with `</p>\n` // pulldown_cmark finishes a paragraph with `</p>\n`
.trim_right_matches("</p>\n")
.trim_end_matches("</p>\n")
.to_string(); .to_string();
} }




+ 1
- 1
src/cmd/init.rs 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 search = ask_bool("> Do you want to build a search index of the content?", false)?;


let config = CONFIG let config = CONFIG
.trim_left()
.trim_start()
.replace("%BASE_URL%", &base_url) .replace("%BASE_URL%", &base_url)
.replace("%COMPILE_SASS%", &format!("{}", compile_sass)) .replace("%COMPILE_SASS%", &format!("{}", compile_sass))
.replace("%SEARCH%", &format!("{}", search)) .replace("%SEARCH%", &format!("{}", search))


Loading…
Cancel
Save