FB2 writer: add cover image specified by "cover-image" meta

Fixes #4195
This commit is contained in:
Alexander Krotov 2017-12-28 16:02:42 +03:00
parent 52a4cf6699
commit 0fd7ed0cab

View file

@ -121,9 +121,18 @@ description meta' = do
Just (MetaString s) -> [el "lang" $ iso639 s]
_ -> []
where iso639 = takeWhile (/= '-') -- Convert BCP 47 to ISO 639
let coverimage url = do
let img = Image nullAttr mempty (url, "")
im <- insertImage InlineImage img
return [el "coverpage" im]
coverpage <- case lookupMeta "cover-image" meta' of
Just (MetaInlines [Str s]) -> coverimage s
Just (MetaString s) -> coverimage s
_ -> return []
return $ el "description"
[ el "title-info" (genre : (bt ++ as ++ dd ++ lang))
, el "document-info" [ el "program-used" "pandoc" ] -- FIXME: +version
, el "document-info" ([ el "program-used" "pandoc" ] -- FIXME: +version
++ coverpage)
]
booktitle :: PandocMonad m => Meta -> FBM m [Content]