git.iko.soy/typeable/pandoc
on master help sign in
ODT/OpenDocument writer: Minor changes for ODF 1.2 conformance.
eb0c0b8John MacFarlane
data/reference.odt

Binary file not shown.

data/templates+1−1

Submodule changed.

src/Text/Pandoc/Writers/ODT.hs+14−6
@@ -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")
77 ]
80 ]
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\"?>"
82 $$
86 $$
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 )
90 )
94 )
@@ -107,7 +111,11 @@ writeODT opts doc@(Pandoc meta _) = do
107 )
111 )
108 )
112 )
109 )
113 )
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''
112
120
113transformPic :: WriterOptions -> IORef [Entry] -> Inline -> IO Inline
121transformPic :: WriterOptions -> IORef [Entry] -> Inline -> IO Inline
src/Text/Pandoc/Writers/OpenDocument.hs+2−1
@@ -461,7 +461,8 @@ tableStyle :: Int -> [(Char,Double)] -> Doc
461tableStyle num wcs =
461tableStyle num wcs =
462 let tableId = "Table" ++ show (num + 1)
462 let tableId = "Table" ++ show (num + 1)
463 table = inTags True "style:style"
463 table = inTags True "style:style"
464− [("style:name", tableId)] $
464+ [("style:name", tableId)
465+ ,("style:family", "table")] $
465 selfClosingTag "style:table-properties"
466 selfClosingTag "style:table-properties"
466 [("table:align" , "center")]
467 [("table:align" , "center")]
467 colStyle (c,0) = selfClosingTag "style:style"
468 colStyle (c,0) = selfClosingTag "style:style"
tests/writer.opendocument+1−1
@@ -1,5 +1,5 @@
1<?xml version="1.0" encoding="utf-8" ?>
1<?xml version="1.0" encoding="utf-8" ?>
2−<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.0">
2+<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.2">
3 <office:automatic-styles>
3 <office:automatic-styles>
4 <text:list-style style:name="L1">
4 <text:list-style style:name="L1">
5 <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">
5 <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">