simonmichael / hledger_site

The repo for hledger.org, the hledger project's website.
GNU General Public License v3.0
63 stars 37 forks source link

Print shows comments #100

Closed holmescharles closed 7 months ago

holmescharles commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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.