-
-
Notifications
You must be signed in to change notification settings - Fork 304
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
journal: Fully unbracket AccountNames in account directives #1987
journal: Fully unbracket AccountNames in account directives #1987
Conversation
7a9de83
to
a2de4e3
Compare
a2de4e3
to
30a7079
Compare
Thanks! I don't love the recursive stripping of all enclosing parentheses/brackets - it looks capable of hiding infinite loop bugs. Eg if textUnbracket changed somehow in future. Our journal format defines only a single enclosing pair of parentheses or brackets. Ledger treats But I see current hledger already strips multiple enclosing pairs:
but not perfectly:
Whether we decide to strip one enclosing pair, strip unlimited enclosing pairs, or raise an error when we see more than one enclosing pair, ideally it will be consistent everywhere. I currently would feel fine with any of these, if we can be sure of not risking infinite loops. |
30a7079
to
4b2c365
Compare
Ah yes, I agree the recursive solution is not the cleanest and could indeed cause some unexpected behaviour later. concatAccountNames :: [AccountName] -> AccountName
concatAccountNames as = accountNameWithPostingType t $ T.intercalate ":" $ map accountNameWithoutPostingType as
where t = headDef RegularPosting $ filter (/= RegularPosting) $ map accountNamePostingType as
To solve your issue with recursion and generalise the unbracketing of account names I changed the It looks like |
Currently an account name like "a:(aa)" will not have (aa) unbracketed. However, this seems reasonable since the full name is unbracketed and thus will not be confused with virtual or virtual-balanced posting.
4b2c365
to
64e69c2
Compare
I see the latest behaviour is to strip all outer bracket or parenthesis pairs enclosing the full account name, leaving single brackets/parentheses or inner bracket/parenthesis pairs unchanged. Practically speaking I think it means users can use brackets or parentheses inside account names, or enclose account name parts other than the top-level part, if they really want to. But they can't enclose a top level part, or a full account name. The new textUnbracket is clever, I had to read it carefully to understand it. Looks good to me, I'll merge if you're ready. |
I'm ready! Yeah it's too bad |
But it seems nice and safe. Thank you! |
Currently an account name like "a:(aa)" will not have (aa) unbracketed. However, this seems reasonable since the full name is unbracketed and thus will not be confused with virtual or virtual-balanced posting.
Resolves #1915