git.iko.soy/typeable/pandoc
on master help sign in
Updated code example.
commit4ba5ef46aeaf979bd74d8f4a5f6cea116527ddd3 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 20 Jun 2017, 21:25 (9 years ago) parent5ec84bf
1 file changed+10−4
src/Text/Pandoc.hs+10−4
src/Text/Pandoc.hs+10−4
@@ -39,12 +39,18 @@ inline links:
3939
4040> module Main where
4141> import Text.Pandoc
42+> import Data.Text (Text)
43+> import qualified Data.Text.IO as T
4244>
43−> markdownToRST :: String -> Either PandocError String
44−> markdownToRST =
45−> writeRST def {writerReferenceLinks = True} . readMarkdown def
45+> mdToRST :: Text -> IO Text
46+> mdToRST txt = runIOorExplode $
47+> readMarkdown def txt
48+> >>= writeRST def{ writerReferenceLinks = True }
49+
4650>
47−> main = getContents >>= either error return markdownToRST >>= putStrLn
51+> main :: IO ()
52+> main = do
53+> T.getContents >>= mdToRST >>= T.putStrLn
4854
4955Note: all of the readers assume that the input text has @'\n'@
5056line endings. So if you get your input text from a web form,