aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrant Ammons <gammons@gmail.com>2017-03-26 05:42:10 -0400
committerGitHub <noreply@github.com>2017-03-26 05:42:10 -0400
commit40be25720ac4686ca07db0b3b7f18ceb39776eb6 (patch)
treebb6b474664c0ad8726c42af9953c96126923423b
parentbd1c22d1af9cde98a7e1340df4d6d4e187b6b889 (diff)
parent91c11630ef1e0a5394754def253876507ac8b94d (diff)
Merge pull request #47 from rdumont/feature/project-hyphen
Adds support to projects with hyphen
-rw-r--r--todolist/parser.go4
-rw-r--r--todolist/parser_test.go7
2 files changed, 7 insertions, 4 deletions
diff --git a/todolist/parser.go b/todolist/parser.go
index 72f6d67..ca5083a 100644
--- a/todolist/parser.go
+++ b/todolist/parser.go
@@ -38,7 +38,7 @@ func (p *Parser) Subject(input string) string {
}
func (p *Parser) ExpandProject(input string) string {
- r, _ := regexp.Compile(`(ex|expand) +\d+ +\+[\p{L}\d_]+:`)
+ r, _ := regexp.Compile(`(ex|expand) +\d+ +\+[\p{L}\d_-]+:`)
pattern := r.FindString(input)
if len(pattern) == 0 {
return ""
@@ -50,7 +50,7 @@ func (p *Parser) ExpandProject(input string) string {
}
func (p *Parser) Projects(input string) []string {
- r, _ := regexp.Compile(`\+[\p{L}\d_]+`)
+ r, _ := regexp.Compile(`\+[\p{L}\d_-]+`)
return p.matchWords(input, r)
}
diff --git a/todolist/parser_test.go b/todolist/parser_test.go
index cbb94e8..8cd6b53 100644
--- a/todolist/parser_test.go
+++ b/todolist/parser_test.go
@@ -42,8 +42,8 @@ func TestParseExpandProjects(t *testing.T) {
func TestParseProjects(t *testing.T) {
parser := &Parser{}
- todo := parser.ParseNewTodo("do this thing +proj1 +proj2 +專案3 due tomorrow")
- if len(todo.Projects) != 3 {
+ todo := parser.ParseNewTodo("do this thing +proj1 +proj2 +專案3 +proj-name due tomorrow")
+ if len(todo.Projects) != 4 {
t.Error("Expected Projects length to be 3")
}
if todo.Projects[0] != "proj1" {
@@ -55,6 +55,9 @@ func TestParseProjects(t *testing.T) {
if todo.Projects[2] != "專案3" {
t.Error("todo.Projects[2] should equal '專案3' but got", todo.Projects[2])
}
+ if todo.Projects[3] != "proj-name" {
+ t.Error("todo.Projects[3] should equal 'proj-name' but got", todo.Projects[3])
+ }
}
func TestParseContexts(t *testing.T) {