mhansen / hledger-vscode

VSCode plugin for HLedger accounting journal file
MIT License
38 stars 9 forks source link

Hashtags in transaction descriptions are being highlighted as comments #347

Closed darylwright closed 8 months ago

darylwright commented 11 months ago

In transaction descriptions that contain a hashtag, the syntax highlighter incorrectly interprets it as a comment. This is misleading and may cause a user to unnecessarily edit a transaction to remove the highlight. Example:

2023-08-15 SOBEYS #680 ; The comment starts at this semicolon, but highlighter indicates that it starts at the hashtag
    Liabilities:My Credit Card    -43.42
    Expenses:Groceries             43.42

Please see this discussion for information on how transaction descriptions are parsed. To summarize:

  • transaction descriptions can contain any characters other than semicolon
  • an asterisk and space at the start of the description could be interpreted as a transaction status mark
  • parenthesised text at the start of the description could be interpreted as a transaction code
  • the first pipe character separates payee and note subfields and can not be escaped
  • a semicolon starts a comment and can not be escaped. (# and * do not start a comment except at the start of a line.)
  • comments can contain any characters
  • words followed by a full colon within comments are interpreted as tags
mhansen commented 11 months ago

Thanks for this clear bug report. You’re right.

On Mon, 18 Sep 2023 at 04:16, Daryl Wright @.***> wrote:

In transaction descriptions that contain a hashtag, the syntax highlighter incorrectly interprets it as a comment. This is misleading and may cause a user to unnecessarily edit a transaction to remove the highlight. Example:

2023-08-15 SOBEYS #680 ; The comment starts at this semicolon, but highlighter indicates that it starts at the hashtag Liabilities:My Credit Card -43.42 Expenses:Groceries 43.42

Please see this discussion https://www.reddit.com/r/plaintextaccounting/comments/16kfwi8/escaping_special_characters_in_hledger_journals/ for information on how transaction descriptions are parsed. To summarize:

  • transaction descriptions can contain any characters other than semicolon
  • an asterisk and space at the start of the description could be interpreted as a transaction status mark
  • parenthesised text at the start of the description could be interpreted as a transaction code
  • the first pipe character separates payee and note subfields and can not be escaped
  • a semicolon starts a comment and can not be escaped. (# and * do not start a comment except at the start of a line.)
  • comments can contain any characters
  • words followed by a full colon within comments are interpreted as tags

— Reply to this email directly, view it on GitHub https://github.com/mhansen/hledger-vscode/issues/347, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAZYOJWAR3KUC52Q72PUNDX245AZANCNFSM6AAAAAA43YVGOY . You are receiving this because you are subscribed to this thread.Message ID: @.***>