aboutsummaryrefslogtreecommitdiffstats
path: root/todolist/parser.go
diff options
context:
space:
mode:
authorQuey-Liang Kao <s101062801@m101.nthu.edu.tw>2017-01-17 03:18:14 +0800
committerQuey-Liang Kao <s101062801@m101.nthu.edu.tw>2017-01-17 03:18:14 +0800
commitc54a184a24f76eda473f585314716bd567dc14bf (patch)
tree0fa8333469faf10e50a740516081690d0fff953a /todolist/parser.go
parent3813ef4378d25ade98a693bf3eef959754e8af20 (diff)
parent05b64e4315ba17960f5bb2119e79eec2476459b2 (diff)
Merge github.com:NonerKao/todolist
Diffstat (limited to 'todolist/parser.go')
-rw-r--r--todolist/parser.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/todolist/parser.go b/todolist/parser.go
index 433cfc6..6919bd7 100644
--- a/todolist/parser.go
+++ b/todolist/parser.go
@@ -13,6 +13,12 @@ import (
type Parser struct{}
func (p *Parser) ParseNewTodo(input string) *Todo {
+ r, _ := regexp.Compile(`^(add|a)(\\ |)`)
+ input = r.ReplaceAllString(input, "")
+ if input == "" {
+ return nil
+ }
+
todo := NewTodo()
todo.Subject = p.Subject(input)
todo.Projects = p.Projects(input)
@@ -24,8 +30,6 @@ func (p *Parser) ParseNewTodo(input string) *Todo {
}
func (p *Parser) Subject(input string) string {
- r, _ := regexp.Compile(`^(add|a) `)
- input = r.ReplaceAllString(input, "")
if strings.Contains(input, " due") {
index := strings.LastIndex(input, " due")
return input[0:index]