git.iko.soy/typeable/pandoc
on master help sign in
Use System.IO.UTF8 only if ghc < 6.12.

GHC >= 6.12 (base >= 4.2) uses iconv to convert to unicode Strings. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1748 788f1e2b-df1e-0410-8736-df70ead52e1b

commitaab574f9ef78792e53bfc55aa58635ecaf8b2a90 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 31 Dec 2009, 16:48 (17 years ago) parent1b3d589
5 files changed+27−4
src/Text/Pandoc.hs+4−2 src/Text/Pandoc/Shared.hs+6−1 src/hsmarkdown.hs+5 src/markdown2pdf.hs+6 src/pandoc.hs+6−1
src/Text/Pandoc.hs+4−2
@@ -36,14 +36,16 @@ inline links:
3636
3737> module Main where
3838> import Text.Pandoc
39−> import qualified System.IO.UTF8 as U
39+> -- include the following two lines only if you're using ghc < 6.12:
40+> import Prelude hiding (getContents, putStrLn)
41+> import System.IO.UTF8
4042>
4143> markdownToRST :: String -> String
4244> markdownToRST =
4345> (writeRST defaultWriterOptions {writerReferenceLinks = True}) .
4446> readMarkdown defaultParserState
4547>
46−> main = U.getContents >>= U.putStrLn . markdownToRST
48+> main = getContents >>= putStrLn . markdownToRST
4749
4850Note: all of the readers assume that the input text has @'\n'@
4951line endings. So if you get your input text from a web form,
src/Text/Pandoc/Shared.hs+6−1
@@ -119,8 +119,13 @@ import Data.List ( find, isPrefixOf, intercalate )
119119import Network.URI ( parseURI, URI (..), isAllowedInURI )
120120import System.Directory
121121import System.FilePath ( FilePath, (</>) )
122−import Prelude hiding ( putStrLn, writeFile, readFile, getContents )
122+-- Note: ghc >= 6.12 (base >=4.2) supports unicode through iconv
123+-- So we use System.IO.UTF8 only if we have an earlier version
124+#if MIN_VERSION_base(4,2,0)
125+#else
126+import Prelude hiding ( putStr, putStrLn, writeFile, readFile, getContents )
123127import System.IO.UTF8
128+#endif
124129import Data.Generics
125130import qualified Control.Monad.State as S
126131import Control.Monad (join)
src/hsmarkdown.hs+5
@@ -29,8 +29,13 @@ Wrapper around pandoc that emulates Markdown.pl as closely as possible.
2929module Main where
3030import System.Process
3131import System.Environment ( getArgs )
32+-- Note: ghc >= 6.12 (base >=4.2) supports unicode through iconv
33+-- So we use System.IO.UTF8 only if we have an earlier version
34+#if MIN_VERSION_base(4,2,0)
35+#else
3236import Prelude hiding ( putStr, putStrLn, writeFile, readFile, getContents )
3337import System.IO.UTF8
38+#endif
3439import Control.Monad (forM_)
3540
3641main :: IO ()
src/markdown2pdf.hs+6
@@ -9,8 +9,14 @@ import Control.Exception (tryJust, bracket)
99import System.IO (stderr)
1010import System.IO.Error (isDoesNotExistError)
1111import System.Environment ( getArgs, getProgName )
12+-- Note: ghc >= 6.12 (base >=4.2) supports unicode through iconv
13+-- So we use System.IO.UTF8 only if we have an earlier version
14+#if MIN_VERSION_base(4,2,0)
15+#else
1216import Prelude hiding ( putStr, putStrLn, writeFile, readFile, getContents )
1317import System.IO.UTF8
18+#endif
19+import System.IO (hPutStrLn)
1420import System.Exit (ExitCode (..), exitWith)
1521import System.FilePath
1622import System.Directory
src/pandoc.hs+6−1
@@ -45,9 +45,14 @@ import System.Console.GetOpt
4545import Data.Maybe ( fromMaybe )
4646import Data.Char ( toLower )
4747import Data.List ( intercalate, isSuffixOf )
48+import System.IO ( stdout, stderr, hPutStrLn, hPutStr )
49+-- Note: ghc >= 6.12 (base >=4.2) supports unicode through iconv
50+-- So we use System.IO.UTF8 only if we have an earlier version
51+#if MIN_VERSION_base(4,2,0)
52+#else
4853import Prelude hiding ( putStr, putStrLn, writeFile, readFile, getContents )
49−import System.IO ( stdout, stderr )
5054import System.IO.UTF8
55+#endif
5156#ifdef _CITEPROC
5257import Text.CSL
5358import Text.Pandoc.Biblio