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

See #939. We leave the nonconforming contextual-spacing attribute, which is provided by LibreOffice itself and seems to be supported.

commiteb0c0b86ed518982eb5d3336e73ff5cb1d59d87c authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 11 Aug 2013, 17:13 (13 years ago) parent7b975c2
5 files changed+18−9
data/reference.odt data/templates+1−1 src/Text/Pandoc/Writers/ODT.hs+14−6 src/Text/Pandoc/Writers/OpenDocument.hs+2−1 tests/writer.opendocument+1−1
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
6565 doc' <- walkM (transformPic opts picEntriesRef) doc
6666 let newContents = writeOpenDocument opts{writerWrapText = False} doc'
6767 epochtime <- floor `fmap` getPOSIXTime
68− let contentEntry = toEntry "content.xml" epochtime $ fromStringLazy newContents
68+ let contentEntry = toEntry "content.xml" epochtime
69+ $ fromStringLazy newContents
6970 picEntries <- readIORef picEntriesRef
70− let archive = foldr addEntryToArchive refArchive $ contentEntry : picEntries
71+ let archive = foldr addEntryToArchive refArchive
72+ $ contentEntry : picEntries
7173 -- construct META-INF/manifest.xml based on archive
7274 let toFileEntry fp = case getMimeType fp of
7375 Nothing -> empty
7476 Just m -> selfClosingTag "manifest:file-entry"
7577 [("manifest:media-type", m)
7678 ,("manifest:full-path", fp)
79+ ,("manifest:version", "1.2")
7780 ]
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) ]
7983 let manifestEntry = toEntry "META-INF/manifest.xml" epochtime
8084 $ fromStringLazy $ render Nothing
8185 $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
8286 $$
8387 ( 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")]
8590 $ ( selfClosingTag "manifest:file-entry"
8691 [("manifest:media-type","application/vnd.oasis.opendocument.text")
87− ,("manifest:version","1.2")
8892 ,("manifest:full-path","/")]
8993 $$ vcat ( map toFileEntry $ files )
9094 )
@@ -107,7 +111,11 @@ writeODT opts doc@(Pandoc meta _) = do
107111 )
108112 )
109113 )
110− let archive'' = addEntryToArchive metaEntry archive'
114+ -- make sure mimetype is first
115+ let mimetypeEntry = toEntry "mimetype" epochtime
116+ $ fromStringLazy "application/vnd.oasis.opendocument.text"
117+ let archive'' = addEntryToArchive mimetypeEntry
118+ $ addEntryToArchive metaEntry archive'
111119 return $ fromArchive archive''
112120
113121transformPic :: WriterOptions -> IORef [Entry] -> Inline -> IO Inline
src/Text/Pandoc/Writers/OpenDocument.hs+2−1
@@ -461,7 +461,8 @@ tableStyle :: Int -> [(Char,Double)] -> Doc
461461tableStyle num wcs =
462462 let tableId = "Table" ++ show (num + 1)
463463 table = inTags True "style:style"
464− [("style:name", tableId)] $
464+ [("style:name", tableId)
465+ ,("style:family", "table")] $
465466 selfClosingTag "style:table-properties"
466467 [("table:align" , "center")]
467468 colStyle (c,0) = selfClosingTag "style:style"
tests/writer.opendocument+1−1
@@ -1,5 +1,5 @@
11<?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">
33 <office:automatic-styles>
44 <text:list-style style:name="L1">
55 <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=".">