mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
preserve whitespace lines (except after last entry)
This commit is contained in:
parent
daff4bf09e
commit
12ad860d4c
25
Parse.hs
25
Parse.hs
@ -152,12 +152,22 @@ ledger = do
|
||||
return $ LedgerFile modifier_entries periodic_entries entries (unlines final_comment_lines)
|
||||
|
||||
ledgernondatalines :: Parser [String]
|
||||
ledgernondatalines = many (ledgerdirective <|> ledgercommentline <|> do {whiteSpace1; return []})
|
||||
ledgernondatalines = many (ledgerdirective <|> -- treat as comments
|
||||
commentline <|>
|
||||
blankline)
|
||||
|
||||
ledgercommentline :: Parser String
|
||||
ledgercommentline = do
|
||||
char ';'
|
||||
l <- restofline <?> "comment line"
|
||||
ledgerdirective :: Parser String
|
||||
ledgerdirective = char '!' >> restofline <?> "directive"
|
||||
|
||||
blankline :: Parser String
|
||||
blankline =
|
||||
do {s <- many1 spacenonewline; newline; return s} <|>
|
||||
do {newline; return ""} <?> "blank line"
|
||||
|
||||
commentline :: Parser String
|
||||
commentline = do
|
||||
char ';' <?> "comment line"
|
||||
l <- restofline
|
||||
return $ ";" ++ l
|
||||
|
||||
ledgercomment :: Parser String
|
||||
@ -169,9 +179,6 @@ ledgercomment =
|
||||
)
|
||||
<|> return "" <?> "comment"
|
||||
|
||||
ledgerdirective :: Parser String
|
||||
ledgerdirective = char '!' >> restofline <?> "directive"
|
||||
|
||||
ledgermodifierentry :: Parser ModifierEntry
|
||||
ledgermodifierentry = do
|
||||
char '=' <?> "entry"
|
||||
@ -191,7 +198,7 @@ ledgerperiodicentry = do
|
||||
ledgerentry :: Parser LedgerEntry
|
||||
ledgerentry = do
|
||||
preceding <- ledgernondatalines
|
||||
date <- ledgerdate
|
||||
date <- ledgerdate <?> "entry"
|
||||
status <- ledgerstatus
|
||||
code <- ledgercode
|
||||
-- ledger treats entry comments as part of the description, we will too
|
||||
|
Loading…
Reference in New Issue
Block a user