git.iko.soy/typeable/pandoc
on master help sign in
Allow absolute URI as parameter (in this case, content is downloaded).
9fee73dfiddlosopher
README+9−2
@@ -62,12 +62,17 @@ Note that you can specify multiple input files on the command line.
62`pandoc` will concatenate them all (with blank lines between them)
62`pandoc` will concatenate them all (with blank lines between them)
63before parsing:
63before parsing:
64
64
65− pandoc -s ch1.txt ch2.txt refs.txt > book.html
65+ pandoc -s ch1.txt ch2.txt refs.txt > book.html
66
66
67(The `-s` option here tells `pandoc` to produce a standalone HTML file,
67(The `-s` option here tells `pandoc` to produce a standalone HTML file,
68with a proper header, rather than a fragment. For more details on this
68with a proper header, rather than a fragment. For more details on this
69and many other command-line options, see below.)
69and many other command-line options, see below.)
70
70
71+Instead of a filename, you can specify an absolute URI. In this
72+case pandoc will attempt to download the content via HTTP:
73+
74+ pandoc -f html -t markdown http://www.fsf.org
75+
71The format of the input and output can be specified explicitly using
76The format of the input and output can be specified explicitly using
72command-line options. The input format can be specified using the
77command-line options. The input format can be specified using the
73`-r/--read` or `-f/--from` options, the output format using the
78`-r/--read` or `-f/--from` options, the output format using the
@@ -113,7 +118,9 @@ Character encodings
113-------------------
118-------------------
114
119
115All input is assumed to be in the UTF-8 encoding, and all output
120All input is assumed to be in the UTF-8 encoding, and all output
121+is in UTF-8 (unless your version of pandoc was compiled using
122+GHC 6.12 or higher, in which case the local encoding will be used).
116−is in UTF-8. If your local character encoding is not UTF-8 and you use
123+If your local character encoding is not UTF-8 and you use
117accented or foreign characters, you should pipe the input and output
124accented or foreign characters, you should pipe the input and output
118through [`iconv`]. For example,
125through [`iconv`]. For example,
119
126
man/man1/pandoc.1.md+9−3
@@ -26,6 +26,11 @@ format). For output to a file, use the `-o` option:
26
26
27 pandoc -o output.html input.txt
27 pandoc -o output.html input.txt
28
28
29+Instead of a file, an absolute URI may be given. In this case
30+pandoc will fetch the content using HTTP:
31+
32+ pandoc -f html -t markdown http://www.fsf.org
33+
29The input and output formats may be specified using command-line options
34The input and output formats may be specified using command-line options
30(see **OPTIONS**, below, for details). If these formats are not
35(see **OPTIONS**, below, for details). If these formats are not
31specified explicitly, Pandoc will attempt to determine them
36specified explicitly, Pandoc will attempt to determine them
@@ -48,9 +53,10 @@ markdown: the differences are described in the *README* file in
48the user documentation. If standard markdown syntax is desired, the
53the user documentation. If standard markdown syntax is desired, the
49`--strict` option may be used.
54`--strict` option may be used.
50
55
51−Pandoc uses the UTF-8 character encoding for both input and output.
56+Pandoc uses the UTF-8 character encoding for both input and output
57+(unless compiled with GHC 6.12 or higher, in which case it uses
52−If your local character encoding is not UTF-8, you should pipe input
58+the local encoding). If your local character encoding is not UTF-8, you
53−and output through `iconv`:
59+should pipe input and output through `iconv`:
54
60
55 iconv -t utf-8 input.txt | pandoc | iconv -f utf-8
61 iconv -t utf-8 input.txt | pandoc | iconv -f utf-8
56
62
pandoc.cabal+2−1
@@ -145,7 +145,8 @@ Library
145 mtl >= 1.1, network >= 2, filepath >= 1.1,
145 mtl >= 1.1, network >= 2, filepath >= 1.1,
146 process >= 1, directory >= 1,
146 process >= 1, directory >= 1,
147 bytestring >= 0.9, zip-archive >= 0.1.1.4,
147 bytestring >= 0.9, zip-archive >= 0.1.1.4,
148− utf8-string >= 0.3, old-time >= 1
148+ utf8-string >= 0.3, old-time >= 1,
149+ HTTP >= 4000.0
149 if impl(ghc >= 6.10)
150 if impl(ghc >= 6.10)
150 Build-depends: base >= 4 && < 5, syb
151 Build-depends: base >= 4 && < 5, syb
151 else
152 else
src/pandoc.hs+8−1
@@ -59,6 +59,9 @@ import Text.CSL
59import Text.Pandoc.Biblio
59import Text.Pandoc.Biblio
60#endif
60#endif
61import Control.Monad (when, unless)
61import Control.Monad (when, unless)
62+import Network.HTTP
63+import Network.URI (parseURI)
64+import Data.ByteString.Lazy.UTF8 (toString)
62
65
63copyrightMessage :: String
66copyrightMessage :: String
64copyrightMessage = "\nCopyright (C) 2006-8 John MacFarlane\n" ++
67copyrightMessage = "\nCopyright (C) 2006-8 John MacFarlane\n" ++
@@ -731,7 +734,11 @@ main = do
731 let readSources [] = mapM readSource ["-"]
734 let readSources [] = mapM readSource ["-"]
732 readSources srcs = mapM readSource srcs
735 readSources srcs = mapM readSource srcs
733 readSource "-" = getContents
736 readSource "-" = getContents
737+ readSource src = case parseURI src of
738+ Just u -> readURI u
734− readSource src = readFile src
739+ Nothing -> readFile src
740+ readURI uri = simpleHTTP (mkRequest GET uri) >>= getResponseBody >>=
741+ return . toString -- treat all as UTF8
735
742
736 let convertTabs = tabFilter (if preserveTabs then 0 else tabStop)
743 let convertTabs = tabFilter (if preserveTabs then 0 else tabStop)
737
744