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

Print shows comments #100

Closed
holmescharles opened this issue Feb 5, 2024 · 2 comments
Closed

Print shows comments #100

holmescharles opened this issue Feb 5, 2024 · 2 comments
Labels
invalid This doesn't seem right

Comments

@holmescharles
Copy link

holmescharles commented Feb 5, 2024

Hi, according to the documentation, the print command should omit comments, but I am getting inline comments. Stand alone comments are in fact omitted. If this is expected behavior, can someone suggest a way to remove in line comments with hledger? (Otherwise I'll be forced to use sed).

cat <<EOF | hledger -f - print
2018/01/01 * "Income" ; comment 1
  income  100 ; comment 2
  expenses   ; comment 3

; comment 4
EOF

Yields:

2018-01-01 * "Income"  ; comment 1
    income               100  ; comment 2
    expenses                  ; comment 3
@simonmichael
Copy link
Owner

Hi, got a link to that documentation ?

print ignores file-level comment lines, but always preserves comments within transactions. To get rid of them you'd have to post-process the output with a tool like sed. Watch out you don't discard comments containing useful tags.

@holmescharles
Copy link
Author

I should read more carefully... its consistent with your last comment:

https://hledger.org/1.32/hledger.html#print (though you probably don't need it now)

Directives and inter-transaction comments are not shown, currently. This means the print command is somewhat lossy, and if you are using it to reformat/regenerate your journal you should take care to also copy over the directives and inter-transaction comments.

@simonmichael simonmichael added the invalid This doesn't seem right label Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants