Skip to content

Commit f1bd46f

Browse files
adeptsimonmichael
authored andcommitted
;doc: explain comments in "if tables" and order of application
1 parent b0b9e69 commit f1bd46f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

hledger/hledger.m4.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3482,6 +3482,7 @@ they can express many matchers and field assignments in a more compact tabular f
34823482
if,HLEDGERFIELD1,HLEDGERFIELD2,...
34833483
MATCHERA,VALUE1,VALUE2,...
34843484
MATCHERB,VALUE1,VALUE2,...
3485+
; Comment line that explains MATCHERC
34853486
MATCHERC,VALUE1,VALUE2,...
34863487
<empty line>
34873488
```
@@ -3493,13 +3494,15 @@ It should be a non-alphanumeric character like `,` or `|` that does not appear a
34933494

34943495
Each line must contain the same number of separators; empty values are allowed.
34953496
Whitespace can be used in the matcher lines for readability (but not in the if line, currently).
3497+
You can use the comment lines in the table body.
34963498
The table must be terminated by an empty line (or end of file).
34973499

34983500
An if table like the above is interpreted as follows:
34993501
try all of the matchers;
35003502
whenever a matcher succeeds, assign all of the values on that line to the corresponding hledger fields;
3501-
later lines can overrider earlier ones.
3502-
It is equivalent to this sequence of if blocks:
3503+
If multiple lines match, later lines will override fields assigned by the earlier ones - just like the sequence of `if` blocks would behave.
3504+
3505+
If table presented above is equivalent to this sequence of if blocks:
35033506

35043507
```rules
35053508
if MATCHERA
@@ -3512,6 +3515,7 @@ if MATCHERB
35123515
HLEDGERFIELD2 VALUE2
35133516
...
35143517
3518+
; Comment line which explains MATCHERC
35153519
if MATCHERC
35163520
HLEDGERFIELD1 VALUE1
35173521
HLEDGERFIELD2 VALUE2
@@ -3523,6 +3527,7 @@ Example:
35233527
if,account2,comment
35243528
atm transaction fee,expenses:business:banking,deductible? check it
35253529
%description groceries,expenses:groceries,
3530+
;; Comment line that desribes why this particular date is special
35263531
2023/01/12.*Plumbing LLC,expenses:house:upkeep,emergency plumbing call-out
35273532
```
35283533

0 commit comments

Comments
 (0)