Proposal, require that both ( and ) are always escaped in tag values?

The current tag syntax is creating at least one bug in my code and some some confusion when others are trying to read TaskPaper files. I think the solution is to force that ( is escaped in addition to ) which already must be escaped. Unfortunately this change will bread existing tag values that have unescaped (s.

The root of the problem is when you write @tagname( everything that follows is considered tag value up until an unescaped ) is encountered. In some cases this causes confusion, but it also breaks part of TaskPaper’s internal API. The Item.setAttribute method works like this in TaskPaper:

  1. Update the item’s attribute value.
  2. Sync the plain text representation to match the value (i.e. add the @tagname(tagvalue) to the end of the line representing that item)

It’s this second step that can break the API. For example in the bug cases reported above the user has typed @due( and then they try to apply @done(date) by clicking the leading dash. It works internally, because step 1 succeeds. But when @done(date) is appended to the string it really completes the easier @due( tag syntax. @done(date just becomes the value of the @due tag.

The only way that I can think to solve this is to just always require that () are escaped as tag values. That will then make it always safe to add () at the end of an items text without the worry that the added text becomes part of some easier tag. Since the leading unescaped ( will break things up.

I’m likely to make this change in the next release, but since it’s breaking figured I would post here to see if anyone else has a better idea.

1 Like

I think that consistently requiring both types of parentheses to be escaped within tag values makes sense.

I think “everything that follows is considered tag value up until an unescaped ) is encountered” is a workable definition. And easy to understand.

Maybe your sync code should be smarter than just appending something to the line. There are probably other edge cases this would help with, that have nothing to do with parentheses.