@@ -37,7 +37,7 @@ import Text.Pandoc.Readers.TeXMath
3737import Text.PrettyPrint.HughesPJ hiding ( Str )
3838
3939import Control.Applicative ((<$>))
40−import Control.Monad.State
40+import Control.Monad.State hiding ( when )
4141import Data.Char (chr)
4242
4343-- | Auxiliary function to convert Plain block to Para.
@@ -120,16 +120,14 @@ authorToOpenDocument name =
120120-- | Convert Pandoc document to string in OpenDocument format.
121121writeOpenDocument :: WriterOptions -> Pandoc -> String
122122writeOpenDocument opts (Pandoc (Meta title authors date) blocks) =
123− let root = inTags True "office:document-content" openDocumentNameSpaces
124− header = if writerStandalone opts
125− then text (writerHeader opts)
126− else empty
127− (tit, _) = runState (wrap opts title) defaultWriterState
128− meta = if writerStandalone opts
129− then inHeaderTags 1 tit $$
130− (vcat (map authorToOpenDocument authors)) $$
131− (inParagraphTags (text $ escapeStringForXML date))
132− else empty
123+ let when p a = if p then a else empty
124+ root = inTags True "office:document-content" openDocumentNameSpaces
125+ header = when (writerStandalone opts) $ text (writerHeader opts)
126+ title' = case runState (wrap opts title) defaultWriterState of
127+ (t,_) -> if isEmpty t then empty else inHeaderTags 1 t
128+ authors' = when (authors /= []) $ vcat (map authorToOpenDocument authors)
129+ date' = when (date /= []) $ inParagraphTags (text $ escapeStringForXML date)
130+ meta = when (writerStandalone opts) $ title' $$ authors' $$ date'
133131 before = writerIncludeBefore opts
134132 after = writerIncludeAfter opts
135133 (doc, s) = runState (blocksToOpenDocument opts blocks) defaultWriterState