Skip to content

cli: html output: valuation-carrying register links, and tree depth classes - #2770

Open
acinader wants to merge 2 commits into
hledgerorg:mainfrom
acinader:cli-register-value-links
Open

acinader wants to merge 2 commits into
hledgerorg:mainfrom
acinader:cli-register-value-links

Conversation

@acinader

@acinader acinader commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Two small additions hledger's HTML output

Part of a prototype I am working on (https://github.com/acinader/hledger/tree/web-playground, cf #2768)
they live in the hledger package and are useful on their own:

  • With --base-url, register links carry a value parameter naming the
    report's valuation, mirroring --value's WHEN[,COMM] syntax
    (value=cost, end, end,€, then, now, a date). A register that
    converts amounts the same way ends on the figure that was clicked —
    hledger-web's register will use this; anything else ignores
    it. Cost combined with a valuation emits none, as before.
  • In tree mode, html account cells carry their tree depth as a class
    (account depth-N), so a stylesheet can indent the tree and a UI can
    fold it. List mode and other formats are unchanged.

Both are inert until a consumer uses them; the consumer is the
web-playground branch above, and #2768's refactoring.

Test plan:

$ hledger -f examples/sample.journal bal -M -V -O html --base-url '' | grep -o 'value=end' | head -1
value=end
$ hledger -f examples/sample.journal bal -M -B -O html --base-url '' | grep -o 'value=cost' | head -1
value=cost
$ hledger -f examples/sample.journal bal -M -B -V -O html --base-url '' | grep -c 'value='
0
$ hledger -f examples/sample.journal bal --tree -O html | grep -o 'class="account depth-[0-9]"' | sort -u
class="account depth-0"
class="account depth-1"
$ hledger -f examples/sample.journal bal -O html | grep -c depth-
0

Functional tests: hledger/test/balance/base-url.test gains cases 23–24,
and a new hledger/test/balance/html.test pins the depth classes both
ways.

AI usage: Claude (Opus 5.5 and Fable 5), ~5k output tokens.

With --base-url, a report's register links now carry a value parameter naming
the report's valuation, mirroring --value's WHEN[,COMM] syntax: value=cost for
-B, value=end for -V, value=end,COMM for -X COMM, and then, now, or a date for
the other valuations. A register converting amounts the same way ends on the
figure that was clicked. Consumers that do not know it ignore it. Cost combined
with a valuation emits none, and such links open the register unconverted, as
before.

AI usage: Claude (Opus 5.5 and Fable 5), ~3k output tokens.
In tree mode, each html account cell's class is now "account depth-N",
N being the row's depth in the displayed tree, so that a stylesheet
can indent the tree and a UI can fold it. List modeis unchanged.

AI usage: Claude (Opus 5.5 and Fable 5), ~2k output tokens.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant