Skip to content

Commit

Permalink
;doc:journal:tags: clarify multiple tags
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichael committed Jan 15, 2024
1 parent 0a54f63 commit eb6d038
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions hledger/hledger.m4.md
Original file line number Diff line number Diff line change
Expand Up @@ -1585,27 +1585,32 @@ which you can then [search](#queries) or [pivot](#pivoting) on.
They are written as a word (optionally hyphenated) immediately followed by a full colon,
in a transaction or posting or account directive's [comment](#account-comments).
(This is an exception to the usual rule that things in comments are ignored.)
Eg, here four different tags are recorded: one on the checking account,
two on the transaction, and one on the expenses posting:
You can write multiple tags separated by comma, and/or you can add more comment lines
and write more tags there.

Here four different tags are recorded: one on the checking account,
two on the transaction, and two on the expenses posting:

```journal
account assets:checking ; accounttag:
2017/1/16 bought groceries ; transactiontag-1:
; transactiontag-2:
assets:checking $-1
expenses:food $1 ; postingtag:
expenses:food $1 ; postingtag:, another-posting-tag:
```

Postings also inherit tags from their transaction and their account.
And transactions also acquire tags from their postings (and postings' accounts).
So in the example above, the expenses posting effectively has all four tags
(by inheriting from account and transaction),
and the transaction also has all four tags (by acquiring from the expenses posting).

You can list tag names with `hledger tags [NAMEREGEX]`,
or match by tag name with a `tag:NAMEREGEX` query.

### Tag inheritance

Postings also inherit tags from their transaction and their account.
And transactions also acquire tags from their postings (and postings' accounts).
So in the example above, the expenses posting effectively has all five tags
(by inheriting from the account and transaction),
and the transaction also has all five tags (by acquiring from the expenses posting).

### Tag values

Tags can have a value, which is any text after the colon up until a comma or end of line
Expand Down

0 comments on commit eb6d038

Please sign in to comment.