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:
parent
9ac1303660
commit
d97fb5f3c6
1 changed files with 53 additions and 47 deletions
|
@ -94,7 +94,8 @@ writeFB2 opts (Pandoc meta blocks) = flip evalStateT newFB $ do
|
||||||
xlink = "http://www.w3.org/1999/xlink"
|
xlink = "http://www.w3.org/1999/xlink"
|
||||||
in [ uattr "xmlns" xmlns
|
in [ uattr "xmlns" xmlns
|
||||||
, attr ("xmlns", "l") xlink ]
|
, attr ("xmlns", "l") xlink ]
|
||||||
--
|
|
||||||
|
|
||||||
frontpage :: Meta -> FBM [Content]
|
frontpage :: Meta -> FBM [Content]
|
||||||
frontpage meta' = do
|
frontpage meta' = do
|
||||||
t <- cMapM toXml . docTitle $ meta'
|
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)
|
, el "annotation" (map (el "p" . cMap plain)
|
||||||
(docAuthors meta' ++ [docDate meta']))
|
(docAuthors meta' ++ [docDate meta']))
|
||||||
]
|
]
|
||||||
|
|
||||||
description :: Meta -> FBM Content
|
description :: Meta -> FBM Content
|
||||||
description meta' = do
|
description meta' = do
|
||||||
bt <- booktitle meta'
|
bt <- booktitle meta'
|
||||||
|
@ -112,14 +114,17 @@ writeFB2 opts (Pandoc meta blocks) = flip evalStateT newFB $ do
|
||||||
[ el "title-info" (bt ++ as ++ dd)
|
[ el "title-info" (bt ++ as ++ dd)
|
||||||
, el "document-info" [ el "program-used" "pandoc" ] -- FIXME: +version
|
, el "document-info" [ el "program-used" "pandoc" ] -- FIXME: +version
|
||||||
]
|
]
|
||||||
|
|
||||||
booktitle :: Meta -> FBM [Content]
|
booktitle :: Meta -> FBM [Content]
|
||||||
booktitle meta' = do
|
booktitle meta' = do
|
||||||
t <- cMapM toXml . docTitle $ meta'
|
t <- cMapM toXml . docTitle $ meta'
|
||||||
return $ if null t
|
return $ if null t
|
||||||
then []
|
then []
|
||||||
else [ el "book-title" t ]
|
else [ el "book-title" t ]
|
||||||
|
|
||||||
authors :: Meta -> [Content]
|
authors :: Meta -> [Content]
|
||||||
authors meta' = cMap author (docAuthors meta')
|
authors meta' = cMap author (docAuthors meta')
|
||||||
|
|
||||||
author :: [Inline] -> [Content]
|
author :: [Inline] -> [Content]
|
||||||
author ss =
|
author ss =
|
||||||
let ws = words . cMap plain $ 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) ]
|
, el "last-name" (last rest) ]
|
||||||
([]) -> []
|
([]) -> []
|
||||||
in list $ el "author" (names ++ email)
|
in list $ el "author" (names ++ email)
|
||||||
|
|
||||||
docdate :: Meta -> FBM [Content]
|
docdate :: Meta -> FBM [Content]
|
||||||
docdate meta' = do
|
docdate meta' = do
|
||||||
let ss = docDate meta'
|
let ss = docDate meta'
|
||||||
|
|
Loading…
Reference in a new issue