@@ -65,26 +65,30 @@ writeODT opts doc@(Pandoc meta _) = do
65 doc' <- walkM (transformPic opts picEntriesRef) doc
65 doc' <- walkM (transformPic opts picEntriesRef) doc
66 let newContents = writeOpenDocument opts{writerWrapText = False} doc'
66 let newContents = writeOpenDocument opts{writerWrapText = False} doc'
67 epochtime <- floor `fmap` getPOSIXTime
67 epochtime <- floor `fmap` getPOSIXTime
68− let contentEntry = toEntry "content.xml" epochtime $ fromStringLazy newContents
68+ let contentEntry = toEntry "content.xml" epochtime
69+ $ fromStringLazy newContents
69 picEntries <- readIORef picEntriesRef
70 picEntries <- readIORef picEntriesRef
70− let archive = foldr addEntryToArchive refArchive $ contentEntry : picEntries
71+ let archive = foldr addEntryToArchive refArchive
72+ $ contentEntry : picEntries
71 -- construct META-INF/manifest.xml based on archive
73 -- construct META-INF/manifest.xml based on archive
72 let toFileEntry fp = case getMimeType fp of
74 let toFileEntry fp = case getMimeType fp of
73 Nothing -> empty
75 Nothing -> empty
74 Just m -> selfClosingTag "manifest:file-entry"
76 Just m -> selfClosingTag "manifest:file-entry"
75 [("manifest:media-type", m)
77 [("manifest:media-type", m)
76 ,("manifest:full-path", fp)
78 ,("manifest:full-path", fp)
79+ ,("manifest:version", "1.2")
78− let files = [ ent | ent <- filesInArchive archive, not ("META-INF" `isPrefixOf` ent) ]
81+ let files = [ ent | ent <- filesInArchive archive,
82+ not ("META-INF" `isPrefixOf` ent) ]
79 let manifestEntry = toEntry "META-INF/manifest.xml" epochtime
83 let manifestEntry = toEntry "META-INF/manifest.xml" epochtime
80 $ fromStringLazy $ render Nothing
84 $ fromStringLazy $ render Nothing
81 $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
85 $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
83 ( inTags True "manifest:manifest"
87 ( inTags True "manifest:manifest"
84− [("xmlns:manifest","urn:oasis:names:tc:opendocument:xmlns:manifest:1.0")]
88+ [("xmlns:manifest","urn:oasis:names:tc:opendocument:xmlns:manifest:1.0")
89+ ,("manifest:version","1.2")]
85 $ ( selfClosingTag "manifest:file-entry"
90 $ ( selfClosingTag "manifest:file-entry"
86 [("manifest:media-type","application/vnd.oasis.opendocument.text")
91 [("manifest:media-type","application/vnd.oasis.opendocument.text")
87− ,("manifest:version","1.2")
88 ,("manifest:full-path","/")]
92 ,("manifest:full-path","/")]
89 $$ vcat ( map toFileEntry $ files )
93 $$ vcat ( map toFileEntry $ files )
@@ -107,7 +111,11 @@ writeODT opts doc@(Pandoc meta _) = do
114+ -- make sure mimetype is first
115+ let mimetypeEntry = toEntry "mimetype" epochtime
116+ $ fromStringLazy "application/vnd.oasis.opendocument.text"
110− let archive'' = addEntryToArchive metaEntry archive'
117+ let archive'' = addEntryToArchive mimetypeEntry
118+ $ addEntryToArchive metaEntry archive'
111 return $ fromArchive archive''
119 return $ fromArchive archive''
113transformPic :: WriterOptions -> IORef [Entry] -> Inline -> IO Inline
121transformPic :: WriterOptions -> IORef [Entry] -> Inline -> IO Inline