On 03/08/07, Dave Bayer <[EMAIL PROTECTED]> wrote: > I'm actually calling > Markdown.pl on tiny files (source code of lengths a human would read), and > it is certainly sluggish enough to be a fair test.)
I had to do this recently, so you might be interested in my approach: <http://193.219.108.225/code/blogpost/BlogPost.hs> The idea here is to run arbitrary text (blog posts) through Markdown and Smartypants before sending them out to the wider world. The code should be pretty self-contained and easy to follow. It does use waitForProcess but I've done my best to keep it clean. (It could still do with being refactored though; there are still bits or repeated code.) The part you want is about 80% of the way down and looks like this: educate = \s -> markdown s >>= smartypants markdown = convert "Markdown" smartypants = convert "SmartyPants" convertWith conv str = do (hin, hout, herr, proc) <- runInteractiveProcess conv [] Nothing Nothing forkIO $ hPutStr hin str >> hClose hin str' <- hGetContents hout return (str', proc) convert conv input = do bracket (convertWith conv input) (\(_,pc) -> do ret <- waitForProcess pc return (ret==ExitSuccess)) (return . fst) Cheers, D. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe