git.iko.soy/typeable/pandoc
on master help sign in
Allow https: to work in pandoc command line arguments.
9b6f1fcJohn MacFarlane
pandoc.hs+8−5
@@ -35,7 +35,8 @@ import Text.Pandoc.Builder (setMeta)
35import Text.Pandoc.PDF (makePDF)
35import Text.Pandoc.PDF (makePDF)
36import Text.Pandoc.Readers.LaTeX (handleIncludes)
36import Text.Pandoc.Readers.LaTeX (handleIncludes)
37import Text.Pandoc.Shared ( tabFilter, readDataFileUTF8, readDataFile,
37import Text.Pandoc.Shared ( tabFilter, readDataFileUTF8, readDataFile,
38− safeRead, headerShift, normalize, err, warn )
38+ safeRead, headerShift, normalize, err, warn,
39+ openURL )
39import Text.Pandoc.XML ( toEntities )
40import Text.Pandoc.XML ( toEntities )
40import Text.Pandoc.SelfContained ( makeSelfContained )
41import Text.Pandoc.SelfContained ( makeSelfContained )
41import Text.Pandoc.Process (pipeProcess)
42import Text.Pandoc.Process (pipeProcess)
@@ -55,7 +56,6 @@ import Control.Exception.Extensible ( throwIO )
55import qualified Text.Pandoc.UTF8 as UTF8
56import qualified Text.Pandoc.UTF8 as UTF8
56import Control.Monad (when, unless, liftM)
57import Control.Monad (when, unless, liftM)
57import Data.Foldable (foldrM)
58import Data.Foldable (foldrM)
58−import Network.HTTP (simpleHTTP, mkRequest, getResponseBody, RequestMethod(..))
59import Network.URI (parseURI, isURI, URI(..))
59import Network.URI (parseURI, isURI, URI(..))
60import qualified Data.ByteString.Lazy as B
60import qualified Data.ByteString.Lazy as B
61import qualified Data.ByteString as BS
61import qualified Data.ByteString as BS
@@ -1120,10 +1120,13 @@ main = do
1120 readSource "-" = UTF8.getContents
1120 readSource "-" = UTF8.getContents
1121 readSource src = case parseURI src of
1121 readSource src = case parseURI src of
1122 Just u | uriScheme u `elem` ["http:","https:"] ->
1122 Just u | uriScheme u `elem` ["http:","https:"] ->
1123− readURI u
1123+ readURI src
1124 _ -> UTF8.readFile src
1124 _ -> UTF8.readFile src
1125− readURI uri = simpleHTTP (mkRequest GET uri) >>= getResponseBody >>=
1125+ readURI src = do
1126− return . UTF8.toStringLazy -- treat all as UTF8
1126+ res <- openURL src
1127+ case res of
1128+ Left e -> throwIO e
1129+ Right (bs,_) -> return $ UTF8.toString bs
1127
1130
1128 let convertTabs = tabFilter (if preserveTabs then 0 else tabStop)
1131 let convertTabs = tabFilter (if preserveTabs then 0 else tabStop)
1129
1132