irrationalistic / atom-tasks

Handle tasks/todo files in atom
MIT License
154 stars 22 forks source link

escape parens in tag values #84

Closed paulroub closed 6 years ago

paulroub commented 7 years ago

per Proposal, require that both ( and ) are always escaped in tag values? (Hog Bay TaskPaper support), to fix #74

Escape parens when adding a tag with a value (among others, collected project names when marking an item done). Look for an unescaped right paren when retrieving a tag's value.

irrationalistic commented 6 years ago

Thanks for coming up with a solution for this! I'm hoping there's a way we can modify this to not introduce any extra syntax into the content though. Maybe the right way is to not use regular expressions and instead just manually check character-to-character in getAllTags. That way we don't have to mess with write, just read and parse! Thoughts?

paulroub commented 6 years ago

Without the extra syntax, how would you know when you've reached the end of the tag, and not just an embedded )?

irrationalistic commented 6 years ago

You'd end up using counters for open/close. Like every ( is +1 and every ) is -1, then you read characters until the value becomes 0 (which means you've closed out the starting () or you reach the end of the current line!

paulroub commented 6 years ago

Nope. No guarantee that someone won't name a project # I am bad at parens), and then your count will be wrong. Hence the need for escaping in this one (slightly weird) case.

irrationalistic commented 6 years ago

Makes sense. Based on your code, this would only apply to tags added via the package, so I think this is fine :)

You'll just have to rebase on the fixed tests!

irrationalistic commented 6 years ago

Looks good to me! I'll merge it now and then put out a release later today :) Thanks for your input and help on this!