git.iko.soy/typeable/pandoc
on master help sign in
Use utf8-string's System.IO.UTF8 to replace Text.Pandoc.UTF8.
ebcebccfiddlosopher
Main.hs+12−10
@@ -30,7 +30,6 @@ writers.
30-}
30-}
31module Main where
31module Main where
32import Text.Pandoc
32import Text.Pandoc
33−import Text.Pandoc.UTF8
34import Text.Pandoc.ODT
33import Text.Pandoc.ODT
35import Text.Pandoc.Shared ( joinWithSep, HTMLMathMethod (..) )
34import Text.Pandoc.Shared ( joinWithSep, HTMLMathMethod (..) )
36import Text.Pandoc.Highlighting ( languages )
35import Text.Pandoc.Highlighting ( languages )
@@ -38,7 +37,9 @@ import System.Environment ( getArgs, getProgName, getEnvironment )
38import System.Exit ( exitWith, ExitCode (..) )
37import System.Exit ( exitWith, ExitCode (..) )
39import System.FilePath ( takeExtension, takeDirectory )
38import System.FilePath ( takeExtension, takeDirectory )
40import System.Console.GetOpt
39import System.Console.GetOpt
40+import Prelude hiding ( putStrLn, writeFile, readFile, getContents )
41−import System.IO
41+import System.IO ( stdout, stderr )
42+import System.IO.UTF8
42import Data.Maybe ( fromMaybe )
43import Data.Maybe ( fromMaybe )
43import Data.Char ( toLower )
44import Data.Char ( toLower )
44import Control.Monad ( (>>=) )
45import Control.Monad ( (>>=) )
@@ -275,7 +276,7 @@ options =
275 (\arg opt -> do
276 (\arg opt -> do
276 let old = optIncludeInHeader opt
277 let old = optIncludeInHeader opt
277 text <- readFile arg
278 text <- readFile arg
278− return opt { optIncludeInHeader = old ++ fromUTF8 text,
279+ return opt { optIncludeInHeader = old ++ text,
279 optStandalone = True })
280 optStandalone = True })
280 "FILENAME")
281 "FILENAME")
281 "" -- "File to include at end of header (implies -s)"
282 "" -- "File to include at end of header (implies -s)"
@@ -285,7 +286,7 @@ options =
285 (\arg opt -> do
286 (\arg opt -> do
286 let old = optIncludeBeforeBody opt
287 let old = optIncludeBeforeBody opt
287 text <- readFile arg
288 text <- readFile arg
288− return opt { optIncludeBeforeBody = old ++ fromUTF8 text })
289+ return opt { optIncludeBeforeBody = old ++ text })
289 "FILENAME")
290 "FILENAME")
290 "" -- "File to include before document body"
291 "" -- "File to include before document body"
291
292
@@ -294,7 +295,7 @@ options =
294 (\arg opt -> do
295 (\arg opt -> do
295 let old = optIncludeAfterBody opt
296 let old = optIncludeAfterBody opt
296 text <- readFile arg
297 text <- readFile arg
297− return opt { optIncludeAfterBody = old ++ fromUTF8 text })
298+ return opt { optIncludeAfterBody = old ++ text })
298 "FILENAME")
299 "FILENAME")
299 "" -- "File to include after document body"
300 "" -- "File to include after document body"
300
301
@@ -302,7 +303,7 @@ options =
302 (ReqArg
303 (ReqArg
303 (\arg opt -> do
304 (\arg opt -> do
304 text <- readFile arg
305 text <- readFile arg
305− return opt { optCustomHeader = fromUTF8 text,
306+ return opt { optCustomHeader = text,
306 optStandalone = True })
307 optStandalone = True })
307 "FILENAME")
308 "FILENAME")
308 "" -- "File to use for custom header (implies -s)"
309 "" -- "File to use for custom header (implies -s)"
@@ -555,10 +556,11 @@ main = do
555 then putStrLn
556 then putStrLn
556 else writeFile outputFile . (++ "\n")
557 else writeFile outputFile . (++ "\n")
557
558
558− (readSources sources) >>= writeOutput . toUTF8 .
559+ (readSources sources) >>= writeOutput .
559− (writer writerOptions) .
560+ writer writerOptions .
560− (reader startParserState) . tabFilter tabStop .
561+ reader startParserState .
562+ tabFilter tabStop .
561− fromUTF8 . (joinWithSep "\n")
563+ joinWithSep "\n"
562
564
563 where
565 where
564 readSources [] = mapM readSource ["-"]
566 readSources [] = mapM readSource ["-"]
Text/Pandoc.hs+5−7
@@ -36,13 +36,14 @@ inline links:
36
36
37> module Main where
37> module Main where
38> import Text.Pandoc
38> import Text.Pandoc
39−>
39+> import qualified System.IO.UTF8 as U
40+>
40> markdownToRST :: String -> String
41> markdownToRST :: String -> String
41−> markdownToRST = toUTF8 .
42+> markdownToRST =
42> (writeRST defaultWriterOptions {writerReferenceLinks = True}) .
43> (writeRST defaultWriterOptions {writerReferenceLinks = True}) .
43−> (readMarkdown defaultParserState) . fromUTF8
44+> readMarkdown defaultParserState
44>
45>
45−> main = interact markdownToRST
46+> main = U.getContents >>= U.putStrLn . markdownToRST
46
47
47-}
48-}
48
49
@@ -84,8 +85,6 @@ module Text.Pandoc
84 , defaultWriterOptions
85 , defaultWriterOptions
85 -- * Default headers for various output formats
86 -- * Default headers for various output formats
86 , module Text.Pandoc.DefaultHeaders
87 , module Text.Pandoc.DefaultHeaders
87− -- * Functions for converting to and from UTF-8
88− , module Text.Pandoc.UTF8
89 -- * Version
88 -- * Version
90 , pandocVersion
89 , pandocVersion
91 ) where
90 ) where
@@ -108,7 +107,6 @@ import Text.Pandoc.Writers.Man
108import Text.Pandoc.Writers.RTF
107import Text.Pandoc.Writers.RTF
109import Text.Pandoc.Writers.MediaWiki
108import Text.Pandoc.Writers.MediaWiki
110import Text.Pandoc.DefaultHeaders
109import Text.Pandoc.DefaultHeaders
111−import Text.Pandoc.UTF8
112import Text.Pandoc.Shared
110import Text.Pandoc.Shared
113
111
114-- | Version number of pandoc library.
112-- | Version number of pandoc library.
Text/Pandoc/ODT.hs−1
@@ -92,7 +92,6 @@ handlePictures tempODT sourceDirRelative xml = do
92 Just x -> x
92 Just x -> x
93 cursor' <- scanPictures tempODT sourceDirRelative cursor
93 cursor' <- scanPictures tempODT sourceDirRelative cursor
94 let modified = parsed { elContent = toForest $ root cursor' }
94 let modified = parsed { elContent = toForest $ root cursor' }
95− putStrLn $ showTopElement modified
96 return $ showTopElement modified
95 return $ showTopElement modified
97
96
98scanPictures :: FilePath -> FilePath -> Cursor -> IO Cursor
97scanPictures :: 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
37
37
38Released under the GPL.
38Released under the GPL.
39
39
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−
76----------------------------------------------------------------------
40----------------------------------------------------------------------
77ASCIIMathML.js
41ASCIIMathML.js
78Copyright 2005, Peter Jipsen, Chapman University
42Copyright 2005, Peter Jipsen, Chapman University
pandoc.cabal+1−2
@@ -80,14 +80,13 @@ Library
80 Build-depends: highlighting-kate
80 Build-depends: highlighting-kate
81 cpp-options: -DHIGHLIGHTING
81 cpp-options: -DHIGHLIGHTING
82 Build-Depends: parsec < 3, xhtml, mtl, network, filepath, process, directory, xml,
82 Build-Depends: parsec < 3, xhtml, mtl, network, filepath, process, directory, xml,
83− bytestring, binary
83+ bytestring, binary, utf8-string
84 Hs-Source-Dirs: .
84 Hs-Source-Dirs: .
85 Exposed-Modules: Text.Pandoc,
85 Exposed-Modules: Text.Pandoc,
86 Text.Pandoc.Blocks,
86 Text.Pandoc.Blocks,
87 Text.Pandoc.Definition,
87 Text.Pandoc.Definition,
88 Text.Pandoc.CharacterReferences,
88 Text.Pandoc.CharacterReferences,
89 Text.Pandoc.Shared,
89 Text.Pandoc.Shared,
90− Text.Pandoc.UTF8,
91 Text.Pandoc.ODT,
90 Text.Pandoc.ODT,
92 Text.Pandoc.ASCIIMathML,
91 Text.Pandoc.ASCIIMathML,
93 Text.Pandoc.DefaultHeaders,
92 Text.Pandoc.DefaultHeaders,