aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2010-02-02 07:37:01 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2010-02-02 07:37:01 +0000
commit9fee73d2a335e7ea8dbbfc149cfa4be580afbdca (patch)
treee6be265f1e658f773d444ecb31d5167c4ed87cdb /src
parent19b0c72dd18050a00dd77bb3dfddd0d0702d157f (diff)
downloadpandoc-9fee73d2a335e7ea8dbbfc149cfa4be580afbdca.tar.gz
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
Diffstat (limited to 'src')
-rw-r--r--src/pandoc.hs9
1 files changed, 8 insertions, 1 deletions
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)