hledger icon indicating copy to clipboard operation
hledger copied to clipboard

Metadata values compatibility, multi-value tags

Open piegamesde opened this issue 2 years ago • 3 comments
trafficstars

From https://hledger.org/ledger.html#journal-format, about Metadata values: "values are terminated by comma, can have multiple tag/values on one line"

This is problematic, because in ledger format you can write something like key: value1, value2. But then when using hledger the semantics of that line is different, it would be key: value1 with value2 as a separate tag.

Why was this change made? Are there any syntactical alternatives for writing out multiple tag values, and in a way that works for both ledger and hledger?

piegamesde avatar Apr 29 '23 21:04 piegamesde

https://hledger.org/dev/hledger.html#tags were intended to be more intuitive to write than Ledger's ; :tag1:tag2:tag3: (IIRC). At that time, nobody was using tags (AKA metadata) with values much.

The cost has been that hledger doesn't allow commas in tag values, unfortunately. Have you got some real-world examples of needing that ?

Some have proposed allowing only one tag per line, which would solve the problem, at a cost of making multiple short tags over-verbose, and more importantly breaking many existing journals.

simonmichael avatar Apr 30 '23 17:04 simonmichael

Another option, slightly unpleasant but consistent with commodity symbols, would be double-quoting:

....   ; tag1:"value 1, with, commas", tag2: value 2

simonmichael avatar Apr 30 '23 17:04 simonmichael

For example listing multiple persons associated with a transaction in some way, or referencing multiple IDs of some kind of an external issue tracker or something like that. Also I think sometimes tags are used with freeform text values, those may contain commas as well.

I do think a CSV-style escaping/quoting solution would be acceptable, however how would such a line parse in the old ledger format?

piegamesde avatar May 01 '23 09:05 piegamesde