fix(parser): exclude @todo from contexts and support quoted location metadata
- Prevents '@todo' from being added to task contexts. - Adds parsing for location metadata with quoted values, allowing spaces.
This commit is contained in:
@@ -172,7 +172,29 @@ func ParseLine(line string) (Task, error) {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(tok, "@") && len(tok) > 1 {
|
||||
t.Contexts = append(t.Contexts, tok[1:])
|
||||
if tok != "@todo" { // exclude @todo context
|
||||
t.Contexts = append(t.Contexts, tok[1:])
|
||||
}
|
||||
continue
|
||||
}
|
||||
// Special case: location:"value with spaces"
|
||||
if strings.HasPrefix(tok, "location:\"") {
|
||||
val := tok[len("location:\""):]
|
||||
for {
|
||||
// If token ends with a quote, we've reached the end
|
||||
if strings.HasSuffix(val, "\"") {
|
||||
val = val[:len(val)-1]
|
||||
break
|
||||
}
|
||||
// Otherwise, append next token
|
||||
i++
|
||||
if i >= len(toks) {
|
||||
// Unterminated quote, treat as is
|
||||
break
|
||||
}
|
||||
val += " " + toks[i]
|
||||
}
|
||||
t.Metadata["location"] = val
|
||||
continue
|
||||
}
|
||||
if !strings.ContainsAny(tok, " \t") && strings.Contains(tok, ":") {
|
||||
|
||||
Reference in New Issue
Block a user