Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ledger file formatting tool #2207

Open
danihodovic opened this issue Jun 27, 2024 · 3 comments
Open

Ledger file formatting tool #2207

danihodovic opened this issue Jun 27, 2024 · 3 comments
Labels
docs Documentation-related. journal The journal file format, and its features.

Comments

@danihodovic
Copy link

danihodovic commented Jun 27, 2024

I've tried to search the manual and Github for tools that automatically format ledger files (similar to Black for Python or gofmt for Go). I write my ledger file in vim and it ends up with inconsistent formatting, especially between the account and amount which vary for each transaction.

Does a command to format files already exist? If not, how difficult would it be to write?

@simonmichael
Copy link
Owner

simonmichael commented Jun 27, 2024

I think the situation is this:

  1. In the PTA world, only the PTA tools themselves can fully parse their own formats, and they usually have a command for outputting the same format (like print). But none of them does this perfectly, eg hledger print is good at preserving everything within a transaction, but it doesn't preserve directives or inter-transaction comments, so you have to work around that.
  2. There are some editor/IDE addons which can parse and reformat PTA data files. These parse more superficially, and are less strict with their formatting, but they are probably better at preserving data. ledger-mode in Emacs (M-q key), VS Code extensions like hledger-vscode, ledger, and Beancount, and probably some vim addons are some of these.

@simonmichael simonmichael added journal The journal file format, and its features. docs Documentation-related. labels Jun 27, 2024
@danihodovic
Copy link
Author

hledger print does seem to preserve comments which is great, but doesn't format the amounts for transactions consistently

2024-05-31 Manually added fees
    Expenses:Bank:Fees        EUR14.25
    Assets:Bank                  EUR-14.25

2024-06-01 Ice cream
    ; :-)
    Expenses:Ice Cream         EUR2.20
    Assets:Bank                    EUR-8.09

@simonmichael
Copy link
Owner

simonmichael commented Jun 27, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation-related. journal The journal file format, and its features.
Projects
None yet
Development

No branches or pull requests

2 participants