Doesn't handle txn and posting tags/links
It seems bean-black doesn't handle #tags that are on the txn level:
lark.exceptions.UnexpectedCharacters: No terminal matches '#' in the current parser context, at line 14 col 3
#opening-balance
^
Expected one of:
* FLAG
* SECTION_HEADER
* DATE
* METADATA_KEY
* ACCOUNT
* COMMENT
...
File "/home/tbm/.local/lib/python3.9/site-packages/lark/lexer.py", line 537, in lex
raise UnexpectedToken(token, e.allowed, state=parser_state, token_history=[last_token], terminals_by_name=self.root_lexer.terminals_by_name)
lark.exceptions.UnexpectedToken: Unexpected token Token('TAGS', '#opening-balance') at line 14, column 3.
Test case:
2000-01-01 open Assets:Cash
2000-01-01 open Equity:Opening-Balance
2022-01-01 * "Opening balance: cash"
#opening-balance
Assets:Cash 10.00 EUR
Equity:Opening-Balance
Hmm, it seems it doesn't like posting-level tags either:
2000-01-01 open Assets:Cash
2000-01-01 open Equity:Opening-Balance
2022-01-01 * "Opening balance: cash"
Assets:Cash 10.00 EUR
Equity:Opening-Balance
#opening-balance
Same with links btw.
AFAIK beancount never supports links / tags on a separate line, or at posting level.
The official parser happily accepts your example because it ignores any lines starting with [;*:#] or a flag character
(https://github.com/beancount/beancount/blob/5464c2b3dba34774edb87a4d4dc1823dbf98c988/beancount/cparser/scanner.lxx#L342-L346). That being said, those hashtags are simply dropped rather than picked up as tags, as can be verified by bean-report print.
Thanks for your comment.
There are two separate questions:
- Can tags and links (on transaction level) be on separate lines. The answer is yes.
Example:
2000-01-01 open Assets:Cash
2000-01-01 open Equity:Opening-Balance
2022-01-01 * "Opening balance: cash"
#opening-balance
^foo
Assets:Cash 10.00 EUR
Equity:Opening-Balance
bean-report x.beancount print will show them:
...
2022-01-01 * "Opening balance: cash" #opening-balance ^foo
Assets:Cash 10.00 EUR
...
- Posting-level tags/links: I completely forgot that they are currently not allowed in beancount. There is a longstanding ticket to support that but it's not allowed currently. You're right about this and I forgot.
Sorry, you are right about the first point. I just found the rule that picks up those tags / links here, confusingly as part of posting_or_kv_list instead of transaction.