Comments (5)
What's wrong with piping through hledger print (and handling inter transaction content
separately) ?
I suppose I'd want to be very careful not to lose data. So I'd want to be very confident that I'm not going to lose data before releasing anything like this.
I just tried hledger print
on a file, and it complained about a balance assertion, which I could silence with -I
. So that's one problem fixed.
I assumed hledger print
wouldn't show comments inside transactions, or comments at the end of a transaction line. But it appears it does?
Let's try a test for a few language features:
$ cat test.hledger
; Comment
alias X = Y
commodity 1000.00 AUD
include /dev/null
; Comment after newline
2021-01-01 Description ; end of line comment
; Inside transaction comment
Expenses:Post 200 AUD = 300 AUD ; End of post comment
Assets:Bank ; end of bank comment
; End of transaction comment
; Post transaction comment
Let's see how much it preserves:
$ hledger print -f test.hledger -I
2021-01-01 Description ; end of line comment
; Inside transaction comment
Expenses:Post 200.00 AUD = 300 AUD ; End of post comment
Assets:Bank ; end of bank comment
; End of transaction comment
It's good that some of the comments are preserved! But statements for alias
, commodity
, include
, and inter-transaction comments have all gone missing. And I imagine the include
will pull other files in during autoformatting. There's probably a bunch of other more esoteric language features that I don't use (timedot?) that I'd want to be confident in handling correctly before offering an autoformatter. I don't really feel confident in building a parser that will mirror what hledger does precisely (and as hledger changes in future too).
I believe these autoformatters best live alongside the canonical parser: that is, in hledger core, so that the autoformatter parser evolves along with the autoformatter (cf gofmt, rustfmt, clang-format).
from hledger-vscode.
from hledger-vscode.
from hledger-vscode.
What's wrong with piping through hledger print (and handling inter transaction content separately) ?
Nothing at all. It's just that doing so requires a separate script[1]. So it's just a matter of laziness vs. convenience.
At one point, I was using the vim-ledger
plugin solely for reformatting of my file, since it made it very easy. Now that I've moved to vscode, I was hoping I could use hledger-vscode
for the same purpose.
[1]: Here's a script that does the job for me, at least wrt to the include
and default
commands I use at the beginning of a file:
#!/bin/bash
sed '/^20[0-9][0-9]/Q' $1 > /tmp/j
tail -n +2 $1 | hledger -f- print -x -I >> /tmp/j
mv $1{,.bak}
mv /tmp/j $1
from hledger-vscode.
Ah. I misunderstood what @simonmichael meant. I mistakenly thought his question was aimed at me, rather than at @mhansen.
The things that hledger print
(currently) doesn't handle are clearly defined:
- Directives (like
alias
,commodity
,include
,account
, etc.) - Inter-transaction comments
So intra-transaction comments (those attached to transactions and postings) are handled just fine. What aren't handled are inter-transaction comments.
And I imagine the include will pull other files in during autoformatting
Yes, hledger print
respects include
directives. That's why in my short script, I omit the include
and default
directives (which are in the top 2 lines of my file) before passing it on to hledger
: tail -n +2 $1 | hledger -f- print -x -I
.
from hledger-vscode.
Related Issues (14)
- Currency codes get highlighted in the middle of posting descriptions
- Tests failing after vscode-textmate update HOT 4
- Can't run tests: unable to compile typescript
- Timedot support HOT 1
- Unable to install on Arch Linux (needs to be published on Open VSX) HOT 3
- [Feature Request] Parser error reporting HOT 7
- Syntax coloring for effective dates HOT 11
- Currency symbols don't get highlighted if not followed by a number HOT 4
- Syntax highlighting for "revenue" in addition to "income" HOT 1
- Hashtags in transaction descriptions are being highlighted as comments HOT 1
- Generalize account syntax HOT 20
- Consider using vscode-tmgrammar-test for tests
- Can't compile oniguruma dependency HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hledger-vscode.