git.iko.soy/typeable/pandoc
on master help sign in
Add date to EPUB titlepage and metadata.

Closes #323. Thanks to Ralf Stephan for the patch (slightly modified).

commit8ed33f66623778f910eac5a0235b15b336c66278 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSat 12 Nov 2011, 12:25 (15 years ago) parent9a46d75
1 file changed+8−3
src/Text/Pandoc/Writers/EPUB.hs+8−3
src/Text/Pandoc/Writers/EPUB.hs+8−3
@@ -128,12 +128,13 @@ writeEPUB mbStylesheet opts doc@(Pandoc meta _) = do
128128 Pandoc meta [Plain t]
129129 let plainTitle = plainify $ docTitle meta
130130 let plainAuthors = map plainify $ docAuthors meta
131+ let plainDate = plainify $ docDate meta
131132 let contentsData = fromString $ ppTopElement $
132133 unode "package" ! [("version","2.0")
133134 ,("xmlns","http://www.idpf.org/2007/opf")
134135 ,("unique-identifier","BookId")] $
135136 [ metadataElement (writerEPUBMetadata opts')
136− uuid lang plainTitle plainAuthors mbCoverImage
137+ uuid lang plainTitle plainAuthors plainDate mbCoverImage
137138 , unode "manifest" $
138139 [ unode "item" ! [("id","ncx"), ("href","toc.ncx")
139140 ,("media-type","application/x-dtbncx+xml")] $ ()
@@ -208,8 +209,8 @@ writeEPUB mbStylesheet opts doc@(Pandoc meta _) = do
208209 (picEntries ++ cpicEntry ++ cpgEntry ++ chapterEntries) )
209210 return $ fromArchive archive
210211
211−metadataElement :: String -> UUID -> String -> String -> [String] -> Maybe a -> Element
212−metadataElement metadataXML uuid lang title authors mbCoverImage =
212+metadataElement :: String -> UUID -> String -> String -> [String] -> String -> Maybe a -> Element
213+metadataElement metadataXML uuid lang title authors date mbCoverImage =
213214 let userNodes = parseXML metadataXML
214215 elt = unode "metadata" ! [("xmlns:dc","http://purl.org/dc/elements/1.1/")
215216 ,("xmlns:opf","http://www.idpf.org/2007/opf")] $
@@ -225,6 +226,7 @@ metadataElement metadataXML uuid lang title authors mbCoverImage =
225226 [ unode "dc:identifier" ! [("id","BookId")] $ show uuid |
226227 not (elt `contains` "identifier") ] ++
227228 [ unode "dc:creator" ! [("opf:role","aut")] $ a | a <- authors ] ++
229+ [ unode "dc:date" date | not (elt `contains` "date") ] ++
228230 [ unode "meta" ! [("name","cover"), ("content","cover-image")] $ () |
229231 not (isNothing mbCoverImage) ]
230232 in elt{ elContent = elContent elt ++ map Elem newNodes }
@@ -309,6 +311,9 @@ pageTemplate = unlines
309311 , "$for(author)$"
310312 , "<h2 class=\"author\">$author$</h2>"
311313 , "$endfor$"
314+ , "$if(date)$"
315+ , "<h3 class=\"date\">$date$</h3>"
316+ , "$endif$"
312317 , "$else$"
313318 , "<h1>$title$</h1>"
314319 , "$if(toc)$"