mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-19 10:17:35 +03:00
Merge pull request #214 from nilcons-contrib/master
Add support for ledger3 style multi-line comments
This commit is contained in:
commit
403ddcadc2
@ -204,6 +204,11 @@ samplejournal = readJournal' $ unlines
|
||||
," assets:bank:checking $1"
|
||||
," income:salary"
|
||||
,""
|
||||
,"comment"
|
||||
,"multi line comment here"
|
||||
,"for testing purposes"
|
||||
,"end comment"
|
||||
,""
|
||||
,"2008/06/01 gift"
|
||||
," assets:bank:checking $1"
|
||||
," income:gifts"
|
||||
|
@ -164,6 +164,7 @@ journal = do
|
||||
, liftM (return . addPeriodicTransaction) periodictransaction
|
||||
, liftM (return . addHistoricalPrice) historicalpricedirective
|
||||
, emptyorcommentlinep >> return (return id)
|
||||
, multilinecommentp >> return (return id)
|
||||
] <?> "journal transaction or directive"
|
||||
|
||||
-- cf http://ledger-cli.org/3.0/doc/ledger3.html#Command-Directives
|
||||
@ -847,6 +848,15 @@ test_numberp = do
|
||||
|
||||
-- comment parsers
|
||||
|
||||
multilinecommentp :: GenParser Char JournalContext ()
|
||||
multilinecommentp = do
|
||||
string "comment" >> newline
|
||||
go
|
||||
where
|
||||
go = try (string "end comment" >> newline >> return ())
|
||||
<|> (anyLine >> go)
|
||||
anyLine = anyChar `manyTill` newline
|
||||
|
||||
emptyorcommentlinep :: GenParser Char JournalContext ()
|
||||
emptyorcommentlinep = do
|
||||
many spacenonewline >> (comment <|> (many spacenonewline >> newline >> return ""))
|
||||
|
Loading…
Reference in New Issue
Block a user