@@ -119,13 +119,8 @@ writeEPUB sourceDir stylesheet opts doc = do
119 unode "package" ! [("version","2.0")
119 unode "package" ! [("version","2.0")
120 ,("xmlns","http://www.idpf.org/2007/opf")
120 ,("xmlns","http://www.idpf.org/2007/opf")
121 ,("unique-identifier","BookId")] $
121 ,("unique-identifier","BookId")] $
122− [ unode "metadata" ! [("xmlns:dc","http://purl.org/dc/elements/1.1/")
122+ [ metadataElement (writerEPUBMetadata opts')
123− ,("xmlns:opf","http://www.idpf.org/2007/opf")] $
123+ uuid lang plainTitle plainAuthors
124− [ unode "dc:title" plainTitle
125− , unode "dc:language" lang
126− , unode "dc:identifier" ! [("id","BookId")] $ show uuid
128− map (unode "dc:creator" ! [("opf:role","aut")]) plainAuthors
129 , unode "manifest" $
124 , unode "manifest" $
130 [ unode "item" ! [("id","ncx"), ("href","toc.ncx")
125 [ unode "item" ! [("id","ncx"), ("href","toc.ncx")
131 ,("media-type","application/x-dtbncx+xml")] $ ()
126 ,("media-type","application/x-dtbncx+xml")] $ ()
@@ -172,6 +167,25 @@ writeEPUB sourceDir stylesheet opts doc = do
172 contentsEntry : tocEntry : (picEntries ++ chapterEntries) )
167 contentsEntry : tocEntry : (picEntries ++ chapterEntries) )
173 return $ fromArchive archive
168 return $ fromArchive archive
170+metadataElement :: String -> UUID -> String -> String -> [String] -> Element
171+metadataElement metadataXML uuid lang title authors =
172+ let userNodes = parseXML metadataXML
173+ elt = unode "metadata" ! [("xmlns:dc","http://purl.org/dc/elements/1.1/")
174+ ,("xmlns:opf","http://www.idpf.org/2007/opf")] $
175+ filter isDublinCoreElement $ onlyElems userNodes
176+ dublinElements = ["contributor","coverage","creator","date",
177+ "description","format","identifier","language","publisher",
178+ "relation","rights","source","subject","title","type"]
179+ isDublinCoreElement e = qPrefix (elName e) == Just "dc" &&
180+ qName (elName e) `elem` dublinElements
181+ contains e n = not (null (findElements (QName n Nothing (Just "dc")) e))
182+ newNodes = [ unode "dc:title" title | not (elt `contains` "title") ] ++
183+ [ unode "dc:language" lang | not (elt `contains` "language") ] ++
184+ [ unode "dc:identifier" ! [("id","BookId")] $ show uuid |
185+ not (elt `contains` "identifier") ] ++
186+ [ unode "dc:creator" ! [("opf:role","aut")] $ a | a <- authors ]
187+ in elt{ elContent = elContent elt ++ map Elem newNodes }
175transformInline :: HTMLMathMethod
189transformInline :: HTMLMathMethod
176 -> FilePath
190 -> FilePath
177 -> IORef [Entry]
191 -> IORef [Entry]