| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Hledger.Write.Journal
Description
Rendering a journal's items back to journal format, reproducing the original journal file(s). Used by print --export.
Synopsis
- data ItemRenderer = ItemRenderer {
- irTransaction :: Transaction -> Text
- irDirective :: Text -> Maybe Text
- irComment :: Text -> Text
- irCommentBlock :: Text -> Text
- journalItemRenderer :: (Transaction -> Text) -> ItemRenderer
- journalItemsAsText :: ItemRenderer -> [JournalItem] -> [Transaction] -> Text
Documentation
data ItemRenderer Source #
How to render each kind of journal item in some output format.
Constructors
| ItemRenderer | |
Fields
| |
journalItemRenderer :: (Transaction -> Text) -> ItemRenderer Source #
An item renderer for hledger's journal format, reproducing directives and comments as written, and rendering transactions with the given showTransaction-like function (whose trailing blank line is removed).
journalItemsAsText :: ItemRenderer -> [JournalItem] -> [Transaction] -> Text Source #
Render journal items as journal text, reproducing the journal file(s) they were parsed from, with transactions rendered from the given (possibly filtered and processed) transactions.
Directive, comment line and comment block items are rendered as the item renderer specifies (verbatim, for hledger's journal format). Non-exported directives are dropped. Include lines are dropped too, and the included file's items follow inline, beginning a new block (so eg there is a blank line between the entries of adjacent included files). Each transaction placeholder is replaced by the rendering of the next given transaction with that source position, or by nothing if there is none (eg it was filtered out). Any transactions not matching a placeholder (eg from non-journal files) are added at the end, in source position order.
Blank lines are normalised: each transaction, and each group of adjacent directive/comment items (as delimited by blank lines in the source), is a block, and blocks are separated by exactly one blank line. A final transaction is also followed by a blank line, as in ordinary print output.