summaryrefslogtreecommitdiff
path: root/Text
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-06-09 21:07:59 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-06-09 21:07:59 +0000
commit2f882638335684ada09c226b6d8d82510c467a4e (patch)
treeb863eacbf8dd73e7dc7c8c04f825b20a72c3edce /Text
parent8add1cf821c050ecb53089a92d1e37e523f75515 (diff)
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
Diffstat (limited to 'Text')
-rw-r--r--Text/Pandoc/Writers/OpenDocument.hs20
1 files changed, 9 insertions, 11 deletions
diff --git a/Text/Pandoc/Writers/OpenDocument.hs b/Text/Pandoc/Writers/OpenDocument.hs
index 4d82f0207..721b69aee 100644
--- a/Text/Pandoc/Writers/OpenDocument.hs
+++ b/Text/Pandoc/Writers/OpenDocument.hs
@@ -37,7 +37,7 @@ import Text.Pandoc.Readers.TeXMath
import Text.PrettyPrint.HughesPJ hiding ( Str )
import Control.Applicative ((<$>))
-import Control.Monad.State
+import Control.Monad.State hiding ( when )
import Data.Char (chr)
-- | Auxiliary function to convert Plain block to Para.
@@ -120,16 +120,14 @@ authorToOpenDocument name =
-- | Convert Pandoc document to string in OpenDocument format.
writeOpenDocument :: WriterOptions -> Pandoc -> String
writeOpenDocument opts (Pandoc (Meta title authors date) blocks) =
- let root = inTags True "office:document-content" openDocumentNameSpaces
- header = if writerStandalone opts
- then text (writerHeader opts)
- else empty
- (tit, _) = runState (wrap opts title) defaultWriterState
- meta = if writerStandalone opts
- then inHeaderTags 1 tit $$
- (vcat (map authorToOpenDocument authors)) $$
- (inParagraphTags (text $ escapeStringForXML date))
- else empty
+ let when p a = if p then a else empty
+ root = inTags True "office:document-content" openDocumentNameSpaces
+ header = when (writerStandalone opts) $ text (writerHeader opts)
+ title' = case runState (wrap opts title) defaultWriterState of
+ (t,_) -> if isEmpty t then empty else inHeaderTags 1 t
+ authors' = when (authors /= []) $ vcat (map authorToOpenDocument authors)
+ date' = when (date /= []) $ inParagraphTags (text $ escapeStringForXML date)
+ meta = when (writerStandalone opts) $ title' $$ authors' $$ date'
before = writerIncludeBefore opts
after = writerIncludeAfter opts
(doc, s) = runState (blocksToOpenDocument opts blocks) defaultWriterState