From 32f23d021e0cb4aca35f5bbf82f860d2b2b5eb34 Mon Sep 17 00:00:00 2001 From: Sanpi Date: Mon, 9 Jul 2018 12:43:39 +0200 Subject: [PATCH] Allows backslash in project/context names https://github.com/todotxt/todo.txt/issues/13 --- src/parser.rs | 2 +- tests/parser.rs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index 6e36015..54ad8ad 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -83,7 +83,7 @@ fn get_tags(regex: &::regex::Regex, subject: &str) -> Vec { macro_rules! regex_tags_shared { () => { - "(?P^|[\\s]){}(?P[\\w-]+)" + "(?P^|[\\s]){}(?P[\\w\\\\-]+)" }; } diff --git a/tests/parser.rs b/tests/parser.rs index 41cb190..63a4305 100644 --- a/tests/parser.rs +++ b/tests/parser.rs @@ -105,11 +105,13 @@ fn deplucate_contexts() { #[test] fn projects() { - let line = "Email SoAndSo at soandso@example.com +project1 @context2".to_owned(); + let line = + "Email SoAndSo at soandso@example.com +project1 +project1\\subject1 @context2".to_owned(); let task = ::todo_txt::Task { - subject: "Email SoAndSo at soandso@example.com +project1 @context2".to_owned(), + subject: "Email SoAndSo at soandso@example.com +project1 +project1\\subject1 @context2" + .to_owned(), contexts: vec!["context2".to_owned()], - projects: vec!["project1".to_owned()], + projects: vec!["project1".to_owned(), "project1\\subject1".to_owned()], ..Default::default() };