git.iko.soy/typeable/pandoc
on master help sign in
Set ODT title property
commitd25656571a4662a4e67b195daed69e77d80c4c2c authorArlo O'Keeffe <MailToArlo@googlemail.com> dateFri 13 Jul 2012, 15:19 (14 years ago) parent5c56165
1 file changed+21−3
src/Text/Pandoc/Writers/ODT.hs+21−3
src/Text/Pandoc/Writers/ODT.hs+21−3
@@ -36,7 +36,7 @@ import Data.ByteString.Lazy.UTF8 ( fromString )
3636import Codec.Archive.Zip
3737import Data.Time.Clock.POSIX
3838import Paths_pandoc ( getDataFileName )
39−import Text.Pandoc.Shared ( WriterOptions(..) )
39+import Text.Pandoc.Shared hiding (Element)
4040import Text.Pandoc.ImageSize ( readImageSize, sizeInPoints )
4141import Text.Pandoc.MIME ( getMimeType )
4242import Text.Pandoc.Definition
@@ -53,7 +53,7 @@ writeODT :: Maybe FilePath -- ^ Path specified by --reference-odt
5353 -> WriterOptions -- ^ Writer options
5454 -> Pandoc -- ^ Document to convert
5555 -> IO B.ByteString
56−writeODT mbRefOdt opts doc = do
56+writeODT mbRefOdt opts doc@(Pandoc (Meta title _ _) _) = do
5757 let datadir = writerUserDataDir opts
5858 refArchive <- liftM toArchive $
5959 case mbRefOdt of
@@ -98,7 +98,25 @@ writeODT mbRefOdt opts doc = do
9898 )
9999 )
100100 let archive' = addEntryToArchive manifestEntry archive
101− return $ fromArchive archive'
101+ let metaEntry = toEntry "meta.xml" epochtime
102+ $ fromString $ show
103+ $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
104+ $$
105+ ( inTags True "office:document-meta"
106+ [("xmlns:office","urn:oasis:names:tc:opendocument:xmlns:office:1.0")
107+ ,("xmlns:xlink","http://www.w3.org/1999/xlink")
108+ ,("xmlns:dc","http://purl.org/dc/elements/1.1/")
109+ ,("xmlns:meta","urn:oasis:names:tc:opendocument:xmlns:meta:1.0")
110+ ,("xmlns:ooo","http://openoffice.org/2004/office")
111+ ,("xmlns:grddl","http://www.w3.org/2003/g/data-view#")
112+ ,("office:version","1.2")]
113+ $ ( inTagsSimple "office:meta"
114+ $ ( inTagsSimple "dc:title" (text $ escapeStringForXML (stringify title))
115+ )
116+ )
117+ )
118+ let archive'' = addEntryToArchive metaEntry archive'
119+ return $ fromArchive archive''
102120
103121transformPic :: FilePath -> IORef [Entry] -> Inline -> IO Inline
104122transformPic sourceDir entriesRef (Image lab (src,tit)) = do