Skip to content

Regex aliases do not allow forward-slash '/' character #982

Closed

Description

@raehik

The hledger docs show a nice way to rewrite all account names to allow using a period character . instead of a colon : as the account separator:

alias /\./=:

Changing this to an escaped forward slash results in an unexpected syntax error:

hledger: hledger.journal:5:10:
  |
5 | alias /\// = :
  |          ^
unexpected '/'
expecting '='

It seems like the forward slash isn't escaped, so the regex ends early.

Activity

  1. added
    A-BUGSomething wrong, confusing or sub-standard in the software, docs, or user experience.
    journalThe journal file format, and its features.
    on Mar 5, 2019
  2. simonmichael commented on Mar 5, 2019

    @simonmichael
    Member

    Thanks for the report.

  3. raehik commented on Mar 5, 2019

    @raehik
    Author

    have done a tiny bit of Haskell before and might have a look at this tomorrow :)

  4. raehik commented on Mar 9, 2019

    @raehik
    Author

    Looks like regex alias parsing occurs at JournalReader.hs#L438. Line 442 reads the regex. But any / ends it, escaping isn't considered.

  5. raehik commented on Mar 11, 2019

    @raehik
    Author

    Would love to fix this so I can pretend my accounts are directories like a true *nix addict, but I'm not sure how to begin. Rewrite \/ to / and continue reading, perhaps? @simonmichael any chance you could point me to similar/related code, or some tutorials for the do construct?

  6. simonmichael commented on Mar 11, 2019

    @simonmichael
    Member

    @raehik I don't know either, off the top of my head. It's a parsing problem, not too hard I think. If I were you I would (after skimming a few of its tutorials, maybe) get familiar with megaparsec's api/combinators, something in there is bound to be helpful. Once you've done that you could also ask for ideas on #haskell.

  7. simonmichael commented on Mar 11, 2019

    @simonmichael
    Member

    (which you can find by starting at http://hackage.haskell.org/package/megaparsec)

  8. raehik commented on Mar 13, 2019

    @raehik
    Author

    Cheers for the links! I'll do some reading when I can, & I believe building locally worked fine so I can mess around.

  9. added a commit that references this issue on May 11, 2026
  10. added a commit that references this issue on May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-BUGSomething wrong, confusing or sub-standard in the software, docs, or user experience.journalThe journal file format, and its features.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions