From 9fee73d2a335e7ea8dbbfc149cfa4be580afbdca Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Tue, 2 Feb 2010 07:37:01 +0000 Subject: Allow absolute URI as parameter (in this case, content is downloaded). + Adds dependency on HTTP. + If a parameter is an absolute URI, pandoc will try to get the content via HTTP. + So, you can do: pandoc -r html -w markdown http://www.fsf.org git-svn-id: https://pandoc.googlecode.com/svn/trunk@1826 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/pandoc.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pandoc.hs b/src/pandoc.hs index f64f218fe..9b05f054c 100644 --- a/src/pandoc.hs +++ b/src/pandoc.hs @@ -59,6 +59,9 @@ import Text.CSL import Text.Pandoc.Biblio #endif import Control.Monad (when, unless) +import Network.HTTP +import Network.URI (parseURI) +import Data.ByteString.Lazy.UTF8 (toString) copyrightMessage :: String copyrightMessage = "\nCopyright (C) 2006-8 John MacFarlane\n" ++ @@ -731,7 +734,11 @@ main = do let readSources [] = mapM readSource ["-"] readSources srcs = mapM readSource srcs readSource "-" = getContents - readSource src = readFile src + readSource src = case parseURI src of + Just u -> readURI u + Nothing -> readFile src + readURI uri = simpleHTTP (mkRequest GET uri) >>= getResponseBody >>= + return . toString -- treat all as UTF8 let convertTabs = tabFilter (if preserveTabs then 0 else tabStop) -- cgit v1.2.3