git.iko.soy/typeable/pandoc
on master help sign in
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

commit9fee73d2a335e7ea8dbbfc149cfa4be580afbdca authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateTue 2 Feb 2010, 07:37 (17 years ago) parent19b0c72
4 files changed+28−7
README+9−2 man/man1/pandoc.1.md+9−3 pandoc.cabal+2−1 src/pandoc.hs+8−1
README+9−2
@@ -62,12 +62,17 @@ Note that you can specify multiple input files on the command line.
6262`pandoc` will concatenate them all (with blank lines between them)
6363before parsing:
6464
65− pandoc -s ch1.txt ch2.txt refs.txt > book.html
65+ pandoc -s ch1.txt ch2.txt refs.txt > book.html
6666
6767(The `-s` option here tells `pandoc` to produce a standalone HTML file,
6868with a proper header, rather than a fragment. For more details on this
6969and many other command-line options, see below.)
7070
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+
7176The format of the input and output can be specified explicitly using
7277command-line options. The input format can be specified using the
7378`-r/--read` or `-f/--from` options, the output format using the
@@ -113,7 +118,9 @@ Character encodings
113118-------------------
114119
115120All input is assumed to be in the UTF-8 encoding, and all output
116−is in UTF-8. If your local character encoding is not UTF-8 and you use
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).
123+If your local character encoding is not UTF-8 and you use
117124accented or foreign characters, you should pipe the input and output
118125through [`iconv`]. For example,
119126
man/man1/pandoc.1.md+9−3
@@ -26,6 +26,11 @@ format). For output to a file, use the `-o` option:
2626
2727 pandoc -o output.html input.txt
2828
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+
2934The input and output formats may be specified using command-line options
3035(see **OPTIONS**, below, for details). If these formats are not
3136specified explicitly, Pandoc will attempt to determine them
@@ -48,9 +53,10 @@ markdown: the differences are described in the *README* file in
4853the user documentation. If standard markdown syntax is desired, the
4954`--strict` option may be used.
5055
51−Pandoc uses the UTF-8 character encoding for both input and output.
52−If your local character encoding is not UTF-8, you should pipe input
53−and output through `iconv`:
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
58+the local encoding). If your local character encoding is not UTF-8, you
59+should pipe input and output through `iconv`:
5460
5561 iconv -t utf-8 input.txt | pandoc | iconv -f utf-8
5662
pandoc.cabal+2−1
@@ -145,7 +145,8 @@ Library
145145 mtl >= 1.1, network >= 2, filepath >= 1.1,
146146 process >= 1, directory >= 1,
147147 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
149150 if impl(ghc >= 6.10)
150151 Build-depends: base >= 4 && < 5, syb
151152 else
src/pandoc.hs+8−1
@@ -59,6 +59,9 @@ import Text.CSL
5959import Text.Pandoc.Biblio
6060#endif
6161import Control.Monad (when, unless)
62+import Network.HTTP
63+import Network.URI (parseURI)
64+import Data.ByteString.Lazy.UTF8 (toString)
6265
6366copyrightMessage :: String
6467copyrightMessage = "\nCopyright (C) 2006-8 John MacFarlane\n" ++
@@ -731,7 +734,11 @@ main = do
731734 let readSources [] = mapM readSource ["-"]
732735 readSources srcs = mapM readSource srcs
733736 readSource "-" = getContents
734− readSource src = readFile src
737+ readSource src = case parseURI src of
738+ Just u -> readURI u
739+ Nothing -> readFile src
740+ readURI uri = simpleHTTP (mkRequest GET uri) >>= getResponseBody >>=
741+ return . toString -- treat all as UTF8
735742
736743 let convertTabs = tabFilter (if preserveTabs then 0 else tabStop)
737744