git.iko.soy/typeable/pandoc
on master help sign in
FB2 writer: add cover image specified by "cover-image" meta
0fd7ed0Alexander Krotov
src/Text/Pandoc/Writers/FB2.hs+10−1
@@ -121,9 +121,18 @@ description meta' = do
121 Just (MetaString s) -> [el "lang" $ iso639 s]
121 Just (MetaString s) -> [el "lang" $ iso639 s]
122 _ -> []
122 _ -> []
123 where iso639 = takeWhile (/= '-') -- Convert BCP 47 to ISO 639
123 where iso639 = takeWhile (/= '-') -- Convert BCP 47 to ISO 639
124+ let coverimage url = do
125+ let img = Image nullAttr mempty (url, "")
126+ im <- insertImage InlineImage img
127+ return [el "coverpage" im]
128+ coverpage <- case lookupMeta "cover-image" meta' of
129+ Just (MetaInlines [Str s]) -> coverimage s
130+ Just (MetaString s) -> coverimage s
131+ _ -> return []
124 return $ el "description"
132 return $ el "description"
125 [ el "title-info" (genre : (bt ++ as ++ dd ++ lang))
133 [ el "title-info" (genre : (bt ++ as ++ dd ++ lang))
126− , el "document-info" [ el "program-used" "pandoc" ] -- FIXME: +version
134+ , el "document-info" ([ el "program-used" "pandoc" ] -- FIXME: +version
135+ ++ coverpage)
127 ]
136 ]
128
137
129booktitle :: PandocMonad m => Meta -> FBM m [Content]
138booktitle :: PandocMonad m => Meta -> FBM m [Content]