git.iko.soy/typeable/pandoc
on master help sign in
Use utf8-string's System.IO.UTF8 to replace Text.Pandoc.UTF8.

+ removed Text/Pandoc/UTF8.hs + removed UTF8.hs notice from debian/copyright + adjusted main.hs, Text/Pandoc.hs, and Text/Pandoc/ODT.hs to use System.IO.UTF8 instead of Text.Pandoc.UTF8 + Added dependency on utf8-string to pandoc.cabal git-svn-id: https://pandoc.googlecode.com/svn/trunk@1347 788f1e2b-df1e-0410-8736-df70ead52e1b

commitebcebccc3226eae6461fececdcca49fbdfb291e7 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 31 Jul 2008, 23:16 (18 years ago) parent774dc07
6 files changed+18−101
Main.hs+12−10 Text/Pandoc.hs+5−7 Text/Pandoc/ODT.hs−1 Text/Pandoc/UTF8.hs−45 debian/copyright−36 pandoc.cabal+1−2
Main.hs+12−10
@@ -30,7 +30,6 @@ writers.
3030-}
3131module Main where
3232import Text.Pandoc
33−import Text.Pandoc.UTF8
3433import Text.Pandoc.ODT
3534import Text.Pandoc.Shared ( joinWithSep, HTMLMathMethod (..) )
3635import Text.Pandoc.Highlighting ( languages )
@@ -38,7 +37,9 @@ import System.Environment ( getArgs, getProgName, getEnvironment )
3837import System.Exit ( exitWith, ExitCode (..) )
3938import System.FilePath ( takeExtension, takeDirectory )
4039import System.Console.GetOpt
41−import System.IO
40+import Prelude hiding ( putStrLn, writeFile, readFile, getContents )
41+import System.IO ( stdout, stderr )
42+import System.IO.UTF8
4243import Data.Maybe ( fromMaybe )
4344import Data.Char ( toLower )
4445import Control.Monad ( (>>=) )
@@ -275,7 +276,7 @@ options =
275276 (\arg opt -> do
276277 let old = optIncludeInHeader opt
277278 text <- readFile arg
278− return opt { optIncludeInHeader = old ++ fromUTF8 text,
279+ return opt { optIncludeInHeader = old ++ text,
279280 optStandalone = True })
280281 "FILENAME")
281282 "" -- "File to include at end of header (implies -s)"
@@ -285,7 +286,7 @@ options =
285286 (\arg opt -> do
286287 let old = optIncludeBeforeBody opt
287288 text <- readFile arg
288− return opt { optIncludeBeforeBody = old ++ fromUTF8 text })
289+ return opt { optIncludeBeforeBody = old ++ text })
289290 "FILENAME")
290291 "" -- "File to include before document body"
291292
@@ -294,7 +295,7 @@ options =
294295 (\arg opt -> do
295296 let old = optIncludeAfterBody opt
296297 text <- readFile arg
297− return opt { optIncludeAfterBody = old ++ fromUTF8 text })
298+ return opt { optIncludeAfterBody = old ++ text })
298299 "FILENAME")
299300 "" -- "File to include after document body"
300301
@@ -302,7 +303,7 @@ options =
302303 (ReqArg
303304 (\arg opt -> do
304305 text <- readFile arg
305− return opt { optCustomHeader = fromUTF8 text,
306+ return opt { optCustomHeader = text,
306307 optStandalone = True })
307308 "FILENAME")
308309 "" -- "File to use for custom header (implies -s)"
@@ -555,10 +556,11 @@ main = do
555556 then putStrLn
556557 else writeFile outputFile . (++ "\n")
557558
558− (readSources sources) >>= writeOutput . toUTF8 .
559− (writer writerOptions) .
560− (reader startParserState) . tabFilter tabStop .
561− fromUTF8 . (joinWithSep "\n")
559+ (readSources sources) >>= writeOutput .
560+ writer writerOptions .
561+ reader startParserState .
562+ tabFilter tabStop .
563+ joinWithSep "\n"
562564
563565 where
564566 readSources [] = mapM readSource ["-"]
Text/Pandoc.hs+5−7
@@ -36,13 +36,14 @@ inline links:
3636
3737> module Main where
3838> import Text.Pandoc
39−>
39+> import qualified System.IO.UTF8 as U
40+>
4041> markdownToRST :: String -> String
41−> markdownToRST = toUTF8 .
42+> markdownToRST =
4243> (writeRST defaultWriterOptions {writerReferenceLinks = True}) .
43−> (readMarkdown defaultParserState) . fromUTF8
44+> readMarkdown defaultParserState
4445>
45−> main = interact markdownToRST
46+> main = U.getContents >>= U.putStrLn . markdownToRST
4647
4748-}
4849
@@ -84,8 +85,6 @@ module Text.Pandoc
8485 , defaultWriterOptions
8586 -- * Default headers for various output formats
8687 , module Text.Pandoc.DefaultHeaders
87− -- * Functions for converting to and from UTF-8
88− , module Text.Pandoc.UTF8
8988 -- * Version
9089 , pandocVersion
9190 ) where
@@ -108,7 +107,6 @@ import Text.Pandoc.Writers.Man
108107import Text.Pandoc.Writers.RTF
109108import Text.Pandoc.Writers.MediaWiki
110109import Text.Pandoc.DefaultHeaders
111−import Text.Pandoc.UTF8
112110import Text.Pandoc.Shared
113111
114112-- | Version number of pandoc library.
Text/Pandoc/ODT.hs−1
@@ -92,7 +92,6 @@ handlePictures tempODT sourceDirRelative xml = do
9292 Just x -> x
9393 cursor' <- scanPictures tempODT sourceDirRelative cursor
9494 let modified = parsed { elContent = toForest $ root cursor' }
95− putStrLn $ showTopElement modified
9695 return $ showTopElement modified
9796
9897scanPictures :: FilePath -> FilePath -> Cursor -> IO Cursor
Text/Pandoc/UTF8.hsdeleted−45
@@ -1,45 +0,0 @@
1−-- | Functions for converting Unicode strings to UTF-8 and vice versa.
2−--
3−-- Taken from <http://www.cse.ogi.edu/~hallgren/Talks/LHiH/base/lib/UTF8.hs>.
4−-- (c) 2003, OGI School of Science & Engineering, Oregon Health and
5−-- Science University.
6−--
7−-- Modified by Martin Norbaeck
8−-- to pass illegal UTF-8 sequences through unchanged.
9−module Text.Pandoc.UTF8 (
10− fromUTF8,
11− toUTF8
12− ) where
13−
14−-- From the Char module supplied with HBC.
15−
16−-- | Take a UTF-8 string and decode it into a Unicode string.
17−fromUTF8 :: String -> String
18−fromUTF8 "" = ""
19−fromUTF8 ('\xef':'\xbb':'\xbf':cs) = fromUTF8 cs -- skip BOM (byte order marker)
20−fromUTF8 (c:c':cs) | '\xc0' <= c && c <= '\xdf' &&
21− '\x80' <= c' && c' <= '\xbf' =
22− toEnum ((fromEnum c `mod` 0x20) * 0x40 + fromEnum c' `mod` 0x40) : fromUTF8 cs
23−fromUTF8 (c:c':c'':cs) | '\xe0' <= c && c <= '\xef' &&
24− '\x80' <= c' && c' <= '\xbf' &&
25− '\x80' <= c'' && c'' <= '\xbf' =
26− toEnum ((fromEnum c `mod` 0x10 * 0x1000) + (fromEnum c' `mod` 0x40) * 0x40 + fromEnum c'' `mod` 0x40) : fromUTF8 cs
27−fromUTF8 (c:cs) = c : fromUTF8 cs
28−
29−-- | Take a Unicode string and encode it as a UTF-8 string.
30−toUTF8 :: String -> String
31−toUTF8 "" = ""
32−toUTF8 (c:cs) =
33− if c > '\x0000' && c < '\x0080' then
34− c : toUTF8 cs
35− else if c < toEnum 0x0800 then
36− let i = fromEnum c
37− in toEnum (0xc0 + i `div` 0x40) :
38− toEnum (0x80 + i `mod` 0x40) :
39− toUTF8 cs
40− else
41− let i = fromEnum c
42− in toEnum (0xe0 + i `div` 0x1000) :
43− toEnum (0x80 + (i `mod` 0x1000) `div` 0x40) :
44− toEnum (0x80 + i `mod` 0x40) :
45− toUTF8 cs
debian/copyright−36
@@ -37,42 +37,6 @@ Copyright (C) 2008 John MacFarlane and Peter Wang
3737
3838Released under the GPL.
3939
40−----------------------------------------------------------------------
41−UTF8.hs
42−Copyright (c) 2003, OGI School of Science & Engineering, Oregon Health &
43−Science University, All rights reserved.
44−
45−Redistribution and use in source and binary forms, with or without
46−modification, are permitted provided that the following conditions
47−are met:
48−
49−- Redistributions of source code must retain the above copyright
50− notice, this list of conditions and the following disclaimer.
51−
52−- Redistributions in binary form must reproduce the above
53− copyright notice, this list of conditions and the following
54− disclaimer in the documentation and/or other materials provided
55− with the distribution.
56−
57−- Neither the name of OGI or OHSU nor the names of its
58− contributors may be used to endorse or promote products derived
59− from this software without specific prior written permission.
60−
61−THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
62−"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
63−LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
64−A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
65−OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
66−SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
67−TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
68−PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
69−LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
70−NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
71−SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
72−
73−This version of UTF8.hs was Modified by Martin Norbäck, to pass illegal
74−utf-8 sequences through unchanged.
75−
7640----------------------------------------------------------------------
7741ASCIIMathML.js
7842Copyright 2005, Peter Jipsen, Chapman University
pandoc.cabal+1−2
@@ -80,14 +80,13 @@ Library
8080 Build-depends: highlighting-kate
8181 cpp-options: -DHIGHLIGHTING
8282 Build-Depends: parsec < 3, xhtml, mtl, network, filepath, process, directory, xml,
83− bytestring, binary
83+ bytestring, binary, utf8-string
8484 Hs-Source-Dirs: .
8585 Exposed-Modules: Text.Pandoc,
8686 Text.Pandoc.Blocks,
8787 Text.Pandoc.Definition,
8888 Text.Pandoc.CharacterReferences,
8989 Text.Pandoc.Shared,
90− Text.Pandoc.UTF8,
9190 Text.Pandoc.ODT,
9291 Text.Pandoc.ASCIIMathML,
9392 Text.Pandoc.DefaultHeaders,