jonestristand / hledger-parser

A parser for ledger/hledger journal files based on Chevrotain
MIT License
13 stars 2 forks source link

Doesn't parser payee info when there are 3 | #2

Closed tbm closed 7 months ago

tbm commented 2 years ago

Usually you use Payee | Narration in the description but there's nothing in the syntax that stops you from having 3 or more | characters:

const sourceCode = `2015/5/30 foo | bar | baz
    Assets:A        10.00 EUR 
    Assets:B       -10.00 EUR 
`;                            

However, this gives:

/home/tbm/tt/node_modules/@jones.tristand/hledger-parser/build/main/index.js:155
    const rawJournal = cst_to_raw_1.default.journal(cstJournal.children);
                                                               ^

TypeError: Cannot read property 'children' of undefined
    at parseLedgerToRaw (/home/tbm/tt/node_modules/@jones.tristand/hledger-parser/build/main/index.js:155:64)
    at parseLedgerToCooked (/home/tbm/tt/node_modules/@jones.tristand/hledger-parser/build/main/index.js:225:52)
    at file:///home/tbm/tt/e.js:10:21
darylwright commented 11 months ago

To add context, only the first pipe is significant for distinguishing the payee and memo. So the expected behaviour is for any subsequent pipes to be read as normal memo text.