From 4ba5ef46aeaf979bd74d8f4a5f6cea116527ddd3 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 20 Jun 2017 21:25:39 +0200 Subject: Updated code example. --- src/Text/Pandoc.hs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs index 8ee1adf13..b8dba860a 100644 --- a/src/Text/Pandoc.hs +++ b/src/Text/Pandoc.hs @@ -39,12 +39,18 @@ inline links: > module Main where > import Text.Pandoc +> import Data.Text (Text) +> import qualified Data.Text.IO as T > -> markdownToRST :: String -> Either PandocError String -> markdownToRST = -> writeRST def {writerReferenceLinks = True} . readMarkdown def +> mdToRST :: Text -> IO Text +> mdToRST txt = runIOorExplode $ +> readMarkdown def txt +> >>= writeRST def{ writerReferenceLinks = True } + > -> main = getContents >>= either error return markdownToRST >>= putStrLn +> main :: IO () +> main = do +> T.getContents >>= mdToRST >>= T.putStrLn Note: all of the readers assume that the input text has @'\n'@ line endings. So if you get your input text from a web form, -- cgit v1.2.3