From b72f9697a29e49745caee719af154cc1dd8974be Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 13 Oct 2018 13:09:49 -0700 Subject: [PATCH] lib: journal: account: allow whitespace or a comment after the account name --- hledger-lib/Hledger/Read/JournalReader.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hledger-lib/Hledger/Read/JournalReader.hs b/hledger-lib/Hledger/Read/JournalReader.hs index 75abe6e40..074455408 100644 --- a/hledger-lib/Hledger/Read/JournalReader.hs +++ b/hledger-lib/Hledger/Read/JournalReader.hs @@ -261,7 +261,7 @@ accountdirectivep = do -- the account name, possibly modified by preceding alias or apply account directives acct <- modifiedaccountnamep -- and maybe something else after two or more spaces ? - matype :: Maybe AccountType <- lift $ fmap (fromMaybe Nothing) $ optional $ do + matype :: Maybe AccountType <- lift $ fmap (fromMaybe Nothing) $ optional $ try $ do skipSome spacenonewline -- at least one more space in addition to the one consumed by modifiedaccountp choice [ -- a numeric account code, as supported in 1.9-1.10 ? currently ignored @@ -273,8 +273,9 @@ accountdirectivep = do ,char 'R' >> return (Just Revenue) ,char 'X' >> return (Just Expense) ] - newline - -- Ledger-style indented subdirectives on following lines ? ignore + -- and maybe a comment on this and/or following lines ? (ignore for now) + (_cmt, _tags) <- lift transactioncommentp + -- and maybe Ledger-style subdirectives ? (ignore) skipMany indentedlinep -- update the journal @@ -820,7 +821,7 @@ tests_JournalReader = tests "JournalReader" [ ] ,test "accountdirectivep" $ do - test "account" $ expectParse accountdirectivep "account a:b\n" + test "account" $ expectParse accountdirectivep "account a:b ; a comment and some:tag, another comment\n" test "does not support !" $ expectParseError accountdirectivep "!account a:b\n" "" ,test "commodityconversiondirectivep" $ do