Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update balance and posting regex to allow leading digits
The beancount documentation around what makes an allowable "Account name" is subtle, and has been very slightly misinterpreted here in vim-beancount. Here's what the doc (https://beancount.github.io/docs/beancount_language_syntax.html#accounts) says: "An account name is a colon-separated list of capitalized words which begin with a letter, and whose first word must be one of five account types (Assets Liabilities Equity Income Expenses). Each component of the account names begin with a capital letter or a number and are followed by letters, numbers or dash (-) characters. All other characters are disallowed." This has been interpreted here that the leading character of each *component* must be a capital letter, whereas actually the 2nd, and later, components may start with a number. As can be seen in the actual beancount/v2 code (https://github.com/beancount/beancount/blob/v2/beancount/core/account.py#L28), the "first character must be upper case" requirement is *only* true of the first/root account name component, which is limited to Assets/Liabilities/Equity/Income/Expenses, so that's true regardless. This might seem like a minor thing, but vim-beancount's current regex stops auto-alignment of useful account names such as: ``` Assets:ISA:2020-2021 Expenses:Groceries:2019-2020 ``` In other words, forcing the use of workarounds like "...:Y2020-2021". Well, "forcing" if one wants to get consistent automatic alignment across an entire file :-) This commit marries up the vim-beancount regex with the beancount/v2 implementation at https://github.com/beancount/beancount/blob/v2/beancount/core/account.py#L28.
- Loading branch information