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

Differentiate line, inline, and block comments #277

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yutotakano
Copy link

@yutotakano yutotakano commented Dec 26, 2022

hledger supports asterisks as a comment starter, but only for standalone comments not attached to any specific posting. This is written here: https://hledger.org/1.28/hledger.html#payee-and-note

In addition, hledger supports block comments, documented here: https://hledger.org/1.28/hledger.html#comment-blocks

Neither those standalone comments or block comments support tags, so I have omitted those.

This PR changes the parse syntax to support both of these. I have tested this locally, I hope you can accept it! :)

@mhansen
Copy link
Owner

mhansen commented Dec 26, 2022 via email

@yutotakano
Copy link
Author

yutotakano commented Dec 26, 2022

Thanks for the quick reply. I was just writing tests (and fixing the numerous other ones that are now parsed differently), when I realised that one case would behave differently: AccountInComment.

With the new syntax, this will just be parsed as a single comment, with no tag inside. To me, the change makes sense since account names aren't tags, and hledger doesn't do anything with them anyway. But I'd like your opinion as the maintainer, should I allow string.unquoted.tags within the new standalone comments too, just for visuals?

The usual inline-comments behave the same and parse tags as intended.

Before

; This is a comment, containing income:salary, and expenses:food
^
["comment.line"]
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 ["comment.line"]
                                ^^^^^^^^^^^^^
                                ["comment.line","string.unquoted.tag"]
                                             ^^^^^^
                                             ["comment.line"]
                                                   ^^^^^^^^^^^^^^
                                                   ["comment.line","string.unquoted.tag"]

After

; This is a comment, containing income:salary, and expenses:food
^
["comment.line"]
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 ["comment.line"]

@mhansen
Copy link
Owner

mhansen commented Dec 26, 2022 via email

@yutotakano
Copy link
Author

Great, okay. Sorry, I'll be on a slight winter break for a week or two but I'll get to it after.

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.

2 participants