git.iko.soy/typeable/pandoc
on master help sign in
OpenDocument writer: Return empty Doc in title block for null author, title, date.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1282 788f1e2b-df1e-0410-8736-df70ead52e1b

commit2f882638335684ada09c226b6d8d82510c467a4e authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateMon 9 Jun 2008, 21:07 (18 years ago) parent8add1cf
1 file changed+9−11
Text/Pandoc/Writers/OpenDocument.hs+9−11
Text/Pandoc/Writers/OpenDocument.hs+9−11
@@ -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