From effc6a9ed4c31960d53a21b85cdec16c3acfaa9c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 1 May 2013 10:55:06 -0700 Subject: Shared.openURL: Print diagnostic output to stderr, not stdout. --- src/Text/Pandoc/Shared.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index bf988875b..39cc386e8 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -102,7 +102,7 @@ import Text.HTML.TagSoup (renderTagsOptions, RenderOptions(..), Tag(..), import qualified Data.ByteString as B import Network.HTTP (findHeader, rspBody, RequestMethod(..), HeaderName(..), mkRequest) -import Network.Browser (browse, setAllowRedirects, request) +import Network.Browser (browse, setAllowRedirects, setOutHandler, request) #ifdef EMBED_DATA_FILES import Text.Pandoc.Data (dataFiles) import System.FilePath ( joinPath, splitDirectories ) @@ -567,8 +567,10 @@ fetchItem sourceDir s = -- | Read from a URL and return raw data and maybe mime type. openURL :: String -> IO (B.ByteString, Maybe String) -openURL u = getBodyAndMimeType `fmap` - browse (setAllowRedirects True >> request (getRequest' u')) +openURL u = getBodyAndMimeType `fmap` browse + (do setOutHandler (UTF8.hPutStrLn stderr) + setAllowRedirects True + request (getRequest' u')) where getBodyAndMimeType (_, r) = (rspBody r, findHeader HdrContentType r) getRequest' uriString = case parseURI uriString of Nothing -> error ("Not a valid URL: " ++ -- cgit v1.2.3