diff options
author | John MacFarlane <jgm@berkeley.edu> | 2010-12-21 16:59:17 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2010-12-21 16:59:17 -0800 |
commit | c9040249448f00d9713281fb8986fc55376c44a1 (patch) | |
tree | 16e10d7eb672796cff7dc50f885260d28a1fef57 /src/Text/Pandoc | |
parent | e2548a1317d9b67c7786f52f5b7b91fb3bf6b3c8 (diff) | |
download | pandoc-c9040249448f00d9713281fb8986fc55376c44a1.tar.gz |
OpenDocument writer: Updated to use Pretty.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Writers/OpenDocument.hs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 0e8a8bf8b..3dc3bd974 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -35,7 +35,7 @@ import Text.Pandoc.Shared import Text.Pandoc.XML import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Readers.TeXMath -import Text.PrettyPrint.HughesPJ hiding ( Str ) +import Text.Pandoc.Pretty import Text.Printf ( printf ) import Control.Applicative ( (<$>) ) import Control.Arrow ( (***), (>>>) ) @@ -169,7 +169,11 @@ writeOpenDocument opts (Pandoc (Meta title authors date) blocks) = date'' <- inlinesToOpenDocument opts date doc'' <- blocksToOpenDocument opts blocks return (doc'', title'', authors'', date'') - body' = render doc + colwidth = if writerWrapText opts + then Just $ writerColumns opts + else Nothing + render' = render colwidth + body' = render' doc styles = stTableStyles s ++ stParaStyles s ++ stTextStyles s listStyle (n,l) = inTags True "text:list-style" [("style:name", "L" ++ show n)] (vcat l) @@ -178,10 +182,10 @@ writeOpenDocument opts (Pandoc (Meta title authors date) blocks) = reverse $ styles ++ listStyles context = writerVariables opts ++ [ ("body", body') - , ("automatic-styles", render automaticStyles) - , ("title", render title') - , ("date", render date') ] ++ - [ ("author", render a) | a <- authors' ] + , ("automatic-styles", render' automaticStyles) + , ("title", render' title') + , ("date", render' date') ] ++ + [ ("author", render' a) | a <- authors' ] in if writerStandalone opts then renderTemplate context $ writerTemplate opts else body' @@ -288,7 +292,7 @@ blockToOpenDocument o bs r <- vcat <$> mapM (deflistItemToOpenDocument o) b setInDefinitionList False return r - preformatted s = vcat <$> mapM (inPreformattedTags . escapeStringForXML) (lines s) + preformatted s = (flush . vcat) <$> mapM (inPreformattedTags . escapeStringForXML) (lines s) mkBlockQuote b = do increaseIndent i <- paraStyle "Quotations" [] inBlockQuote o i (map plainToPara b) @@ -348,7 +352,7 @@ inlineToOpenDocument o ils | EmDash <- ils = inTextStyle $ text "—" | EnDash <- ils = inTextStyle $ text "–" | Apostrophe <- ils = inTextStyle $ text "’" - | Space <- ils = inTextStyle $ char ' ' + | Space <- ils = inTextStyle space | LineBreak <- ils = return $ selfClosingTag "text:line-break" [] | Str s <- ils = inTextStyle $ handleSpaces $ escapeStringForXML s | Emph l <- ils = withTextStyle Italic $ inlinesToOpenDocument o l |