From 01caa3d9965b7a35310d64f90173984edfd0a087 Mon Sep 17 00:00:00 2001 From: Arthur Milchior Date: Mon, 28 Dec 2020 03:32:05 +0100 Subject: [PATCH] Trim the start of field name if it is #, /, ^ or a whitespace I actually need to trim whitespace again to deal with a field name of the form "# foo" --- rslib/src/notetype/fields.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rslib/src/notetype/fields.rs b/rslib/src/notetype/fields.rs index 6903c4c70..580bb1c8f 100644 --- a/rslib/src/notetype/fields.rs +++ b/rslib/src/notetype/fields.rs @@ -42,7 +42,8 @@ impl NoteField { self.name = self.name.replace(bad_chars, ""); } // and leading/trailing whitespace - let trimmed = self.name.trim(); + let bad_start_chars = |c: char| c == '#' || c == '/' || c == '^' || c.is_whitespace(); + let trimmed = self.name.trim().trim_start_matches(bad_start_chars); if trimmed.len() != self.name.len() { self.name = trimmed.into(); }