aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2011-11-12 12:25:43 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2011-11-12 12:25:43 -0800
commit8ed33f66623778f910eac5a0235b15b336c66278 (patch)
treeae16296218e66c67f9235145d35c1a99f3860ce9
parent9a46d755061713d6656020d554b62f1aaa922def (diff)
downloadpandoc-8ed33f66623778f910eac5a0235b15b336c66278.tar.gz
Add date to EPUB titlepage and metadata.
Closes #323. Thanks to Ralf Stephan for the patch (slightly modified).
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index fe7b8d801..cf5cad253 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -128,12 +128,13 @@ writeEPUB mbStylesheet opts doc@(Pandoc meta _) = do
Pandoc meta [Plain t]
let plainTitle = plainify $ docTitle meta
let plainAuthors = map plainify $ docAuthors meta
+ let plainDate = plainify $ docDate meta
let contentsData = fromString $ ppTopElement $
unode "package" ! [("version","2.0")
,("xmlns","http://www.idpf.org/2007/opf")
,("unique-identifier","BookId")] $
[ metadataElement (writerEPUBMetadata opts')
- uuid lang plainTitle plainAuthors mbCoverImage
+ uuid lang plainTitle plainAuthors plainDate mbCoverImage
, unode "manifest" $
[ unode "item" ! [("id","ncx"), ("href","toc.ncx")
,("media-type","application/x-dtbncx+xml")] $ ()
@@ -208,8 +209,8 @@ writeEPUB mbStylesheet opts doc@(Pandoc meta _) = do
(picEntries ++ cpicEntry ++ cpgEntry ++ chapterEntries) )
return $ fromArchive archive
-metadataElement :: String -> UUID -> String -> String -> [String] -> Maybe a -> Element
-metadataElement metadataXML uuid lang title authors mbCoverImage =
+metadataElement :: String -> UUID -> String -> String -> [String] -> String -> Maybe a -> Element
+metadataElement metadataXML uuid lang title authors date mbCoverImage =
let userNodes = parseXML metadataXML
elt = unode "metadata" ! [("xmlns:dc","http://purl.org/dc/elements/1.1/")
,("xmlns:opf","http://www.idpf.org/2007/opf")] $
@@ -225,6 +226,7 @@ metadataElement metadataXML uuid lang title authors mbCoverImage =
[ unode "dc:identifier" ! [("id","BookId")] $ show uuid |
not (elt `contains` "identifier") ] ++
[ unode "dc:creator" ! [("opf:role","aut")] $ a | a <- authors ] ++
+ [ unode "dc:date" date | not (elt `contains` "date") ] ++
[ unode "meta" ! [("name","cover"), ("content","cover-image")] $ () |
not (isNothing mbCoverImage) ]
in elt{ elContent = elContent elt ++ map Elem newNodes }
@@ -309,6 +311,9 @@ pageTemplate = unlines
, "$for(author)$"
, "<h2 class=\"author\">$author$</h2>"
, "$endfor$"
+ , "$if(date)$"
+ , "<h3 class=\"date\">$date$</h3>"
+ , "$endif$"
, "$else$"
, "<h1>$title$</h1>"
, "$if(toc)$"