FB2 writer: bring functions to toplevel.

This is the first of a number of changes to bring the FB2 writer a bit
closer to the idioms used elsewhere in pandoc, so it can be more easily
converted to using the pure functions from Free.
This commit is contained in:
Jesse Rosenthal 2016-11-18 06:18:12 -05:00 committed by John MacFarlane
parent 9ac1303660
commit d97fb5f3c6

View file

@ -94,7 +94,8 @@ writeFB2 opts (Pandoc meta blocks) = flip evalStateT newFB $ do
xlink = "http://www.w3.org/1999/xlink"
in [ uattr "xmlns" xmlns
, attr ("xmlns", "l") xlink ]
--
frontpage :: Meta -> FBM [Content]
frontpage meta' = do
t <- cMapM toXml . docTitle $ meta'
@ -103,6 +104,7 @@ writeFB2 opts (Pandoc meta blocks) = flip evalStateT newFB $ do
, el "annotation" (map (el "p" . cMap plain)
(docAuthors meta' ++ [docDate meta']))
]
description :: Meta -> FBM Content
description meta' = do
bt <- booktitle meta'
@ -112,14 +114,17 @@ writeFB2 opts (Pandoc meta blocks) = flip evalStateT newFB $ do
[ el "title-info" (bt ++ as ++ dd)
, el "document-info" [ el "program-used" "pandoc" ] -- FIXME: +version
]
booktitle :: Meta -> FBM [Content]
booktitle meta' = do
t <- cMapM toXml . docTitle $ meta'
return $ if null t
then []
else [ el "book-title" t ]
authors :: Meta -> [Content]
authors meta' = cMap author (docAuthors meta')
author :: [Inline] -> [Content]
author ss =
let ws = words . cMap plain $ ss
@ -134,6 +139,7 @@ writeFB2 opts (Pandoc meta blocks) = flip evalStateT newFB $ do
, el "last-name" (last rest) ]
([]) -> []
in list $ el "author" (names ++ email)
docdate :: Meta -> FBM [Content]
docdate meta' = do
let ss = docDate meta'