Add support for ledger3 style multi-line comments
This commit is contained in:
		
							parent
							
								
									e892fdc6d5
								
							
						
					
					
						commit
						6e4a7dff8c
					
				| @ -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