Skip to content

Differentiate line, inline, and block comments - #277

Open
yutotakano wants to merge 1 commit into
mhansen:mainfrom
yutotakano:differentiate-comments
Open

Differentiate line, inline, and block comments#277
yutotakano wants to merge 1 commit into
mhansen:mainfrom
yutotakano:differentiate-comments

Conversation

@yutotakano

@yutotakano yutotakano commented Dec 26, 2022

Copy link
Copy Markdown

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

mhansen commented Dec 26, 2022 via email

Copy link
Copy Markdown
Owner

@yutotakano

yutotakano commented Dec 26, 2022

Copy link
Copy Markdown
Author

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

mhansen commented Dec 26, 2022 via email

Copy link
Copy Markdown
Owner

@yutotakano

Copy link
Copy Markdown
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