diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-07-13 16:40:07 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-07-13 16:40:07 -0700 |
commit | 58838996259d02700db33ca3cbb3fcbca0688e51 (patch) | |
tree | 5b226b4ea040b78e27c3e5ee916cdc01c99f1124 /src/Text/Pandoc/Writers | |
parent | 3e95fd586dfc286cb1bb7300521ccd2a6d11bc1f (diff) | |
download | pandoc-58838996259d02700db33ca3cbb3fcbca0688e51.tar.gz |
RTF writer: Avoid extra paragraph tags in metadata.
Closes #1421.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r-- | src/Text/Pandoc/Writers/RTF.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs index e0428aaa8..5c8c49f3e 100644 --- a/src/Text/Pandoc/Writers/RTF.hs +++ b/src/Text/Pandoc/Writers/RTF.hs @@ -39,6 +39,7 @@ import Data.List ( isSuffixOf, intercalate ) import Data.Char ( ord, chr, isDigit, toLower ) import System.FilePath ( takeExtension ) import qualified Data.ByteString as B +import qualified Data.Map as M import Text.Printf ( printf ) import Network.URI ( isURI, unEscapeString ) import qualified Control.Exception as E @@ -74,12 +75,19 @@ writeRTFWithEmbeddedImages options doc = -- | Convert Pandoc to a string in rich text format. writeRTF :: WriterOptions -> Pandoc -> String -writeRTF options (Pandoc meta blocks) = +writeRTF options (Pandoc meta@(Meta metamap) blocks) = let spacer = not $ all null $ docTitle meta : docDate meta : docAuthors meta + toPlain (MetaBlocks [Para ils]) = MetaInlines ils + toPlain x = x + -- adjust title, author, date so we don't get para inside para + meta' = Meta $ M.adjust toPlain "title" + . M.adjust toPlain "author" + . M.adjust toPlain "date" + $ metamap Just metadata = metaToJSON options (Just . concatMap (blockToRTF 0 AlignDefault)) (Just . inlineListToRTF) - meta + meta' body = concatMap (blockToRTF 0 AlignDefault) blocks isTOCHeader (Header lev _ _) = lev <= writerTOCDepth options isTOCHeader _ = False |