git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #270 from khightower/master

EPUB writer: Add a meta element specify the cover.

commit201e680964b0053b9924dc7519d385cc249cc62e authorJohn MacFarlane <jgm@berkeley.edu> dateTue 5 Jul 2011, 13:46 (15 years ago) parent9b5f1cbcf11673
1 file changed+6−4
src/Text/Pandoc/Writers/EPUB.hs+6−4
src/Text/Pandoc/Writers/EPUB.hs+6−4
@@ -134,7 +134,7 @@ writeEPUB mbStylesheet opts doc@(Pandoc meta _) = do
134134 ,("xmlns","http://www.idpf.org/2007/opf")
135135 ,("unique-identifier","BookId")] $
136136 [ metadataElement (writerEPUBMetadata opts')
137− uuid lang plainTitle plainAuthors
137+ uuid lang plainTitle plainAuthors mbCoverImage
138138 , unode "manifest" $
139139 [ unode "item" ! [("id","ncx"), ("href","toc.ncx")
140140 ,("media-type","application/x-dtbncx+xml")] $ ()
@@ -209,8 +209,8 @@ writeEPUB mbStylesheet opts doc@(Pandoc meta _) = do
209209 (picEntries ++ cpicEntry ++ cpgEntry ++ chapterEntries) )
210210 return $ fromArchive archive
211211
212−metadataElement :: String -> UUID -> String -> String -> [String] -> Element
213−metadataElement metadataXML uuid lang title authors =
212+metadataElement :: String -> UUID -> String -> String -> [String] -> Maybe a -> Element
213+metadataElement metadataXML uuid lang title authors mbCoverImage =
214214 let userNodes = parseXML metadataXML
215215 elt = unode "metadata" ! [("xmlns:dc","http://purl.org/dc/elements/1.1/")
216216 ,("xmlns:opf","http://www.idpf.org/2007/opf")] $
@@ -225,7 +225,9 @@ metadataElement metadataXML uuid lang title authors =
225225 [ unode "dc:language" lang | not (elt `contains` "language") ] ++
226226 [ unode "dc:identifier" ! [("id","BookId")] $ show uuid |
227227 not (elt `contains` "identifier") ] ++
228− [ unode "dc:creator" ! [("opf:role","aut")] $ a | a <- authors ]
228+ [ unode "dc:creator" ! [("opf:role","aut")] $ a | a <- authors ] ++
229+ [ unode "meta" ! [("name","cover"), ("content","cover-image")] $ () |
230+ not (isNothing mbCoverImage) ]
229231 in elt{ elContent = elContent elt ++ map Elem newNodes }
230232
231233transformInlines :: HTMLMathMethod