aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-01-18 10:33:37 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-01-18 10:33:37 -0800
commit8eab759a9c72e98b8e47d7c4b19d6aeb3e24cdcb (patch)
tree4920140f776294e25fefb7a6a2cddba49e045bd5 /src/Text/Pandoc/Writers
parent4aea26e8e1179a2feb1672256b1b9317d2c3baf8 (diff)
downloadpandoc-8eab759a9c72e98b8e47d7c4b19d6aeb3e24cdcb.tar.gz
RTF writer: Added writeRTFWithEmbeddedImages.
* RTF writer: Export writeRTFWithEmbeddedImages instead of rtfEmbedImage. * Text.Pandoc: Use writeRTFWithEmbeddedImages for RTF. * Moved code for embedding images in RTF out of pandoc.hs.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/RTF.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs
index f2a271c1d..ca33cb0e9 100644
--- a/src/Text/Pandoc/Writers/RTF.hs
+++ b/src/Text/Pandoc/Writers/RTF.hs
@@ -27,12 +27,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Conversion of 'Pandoc' documents to RTF (rich text format).
-}
-module Text.Pandoc.Writers.RTF ( writeRTF, rtfEmbedImage ) where
+module Text.Pandoc.Writers.RTF ( writeRTF, writeRTFWithEmbeddedImages ) where
import Text.Pandoc.Definition
import Text.Pandoc.Options
import Text.Pandoc.Shared
import Text.Pandoc.Readers.TeXMath
import Text.Pandoc.Templates (renderTemplate)
+import Text.Pandoc.Generic (bottomUpM)
import Data.List ( isSuffixOf, intercalate )
import Data.Char ( ord, isDigit, toLower )
import System.FilePath ( takeExtension )
@@ -64,6 +65,12 @@ rtfEmbedImage x@(Image _ (src,_)) = do
else return x
rtfEmbedImage x = return x
+-- | Convert Pandoc to a string in rich text format, with
+-- images embedded as encoded binary data.
+writeRTFWithEmbeddedImages :: WriterOptions -> Pandoc -> IO String
+writeRTFWithEmbeddedImages options doc =
+ writeRTF options `fmap` bottomUpM rtfEmbedImage doc
+
-- | Convert Pandoc to a string in rich text format.
writeRTF :: WriterOptions -> Pandoc -> String
writeRTF options (Pandoc (Meta title authors date) blocks) =