git.iko.soy/typeable/pandoc
on master help sign in
Merge commit 'd25656571a4662a4e67b195daed69e77d80c4c2c'

Conflicts: src/Text/Pandoc/Writers/ODT.hs

commita6dcae1648e948bc984683639bf80173cf59ff7b authorJohn MacFarlane <jgm@berkeley.edu> dateThu 23 Aug 2012, 19:26 (14 years ago) parentd7e658cd256565
1 file changed+21−2
src/Text/Pandoc/Writers/ODT.hs+21−2
src/Text/Pandoc/Writers/ODT.hs+21−2
@@ -37,6 +37,7 @@ import Codec.Archive.Zip
3737import Data.Time.Clock.POSIX
3838import Paths_pandoc ( getDataFileName )
3939import Text.Pandoc.Options ( WriterOptions(..) )
40+import Text.Pandoc.Shared ( stringify )
4041import Text.Pandoc.ImageSize ( readImageSize, sizeInPoints )
4142import Text.Pandoc.MIME ( getMimeType )
4243import Text.Pandoc.Definition
@@ -53,7 +54,7 @@ import qualified Control.Exception as E
5354writeODT :: WriterOptions -- ^ Writer options
5455 -> Pandoc -- ^ Document to convert
5556 -> IO B.ByteString
56−writeODT opts doc = do
57+writeODT opts doc@(Pandoc (Meta title _ _) _) = do
5758 let datadir = writerUserDataDir opts
5859 refArchive <- liftM toArchive $
5960 case writerReferenceODT opts of
@@ -98,7 +99,25 @@ writeODT opts doc = do
9899 )
99100 )
100101 let archive' = addEntryToArchive manifestEntry archive
101− return $ fromArchive archive'
102+ let metaEntry = toEntry "meta.xml" epochtime
103+ $ fromString $ show
104+ $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
105+ $$
106+ ( inTags True "office:document-meta"
107+ [("xmlns:office","urn:oasis:names:tc:opendocument:xmlns:office:1.0")
108+ ,("xmlns:xlink","http://www.w3.org/1999/xlink")
109+ ,("xmlns:dc","http://purl.org/dc/elements/1.1/")
110+ ,("xmlns:meta","urn:oasis:names:tc:opendocument:xmlns:meta:1.0")
111+ ,("xmlns:ooo","http://openoffice.org/2004/office")
112+ ,("xmlns:grddl","http://www.w3.org/2003/g/data-view#")
113+ ,("office:version","1.2")]
114+ $ ( inTagsSimple "office:meta"
115+ $ ( inTagsSimple "dc:title" (text $ escapeStringForXML (stringify title))
116+ )
117+ )
118+ )
119+ let archive'' = addEntryToArchive metaEntry archive'
120+ return $ fromArchive archive''
102121
103122transformPic :: FilePath -> IORef [Entry] -> Inline -> IO Inline
104123transformPic sourceDir entriesRef (Image lab (src,tit)) = do