git.iko.soy/typeable/pandoc
on master help sign in
Improved configuration options and CPP macros.

+ Now all macros that serve as flags start with a single _. + Added message to '-v' output about UTF-8 support. + Made highlighting the default. If the highlighting-kate library is not present, cabal will deselect the option (unless it was explicitly set). + Add UTF8 support to test function in Text.Pandoc.Shared. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1374 788f1e2b-df1e-0410-8736-df70ead52e1b

commit6ff1e2a976c61268660da4a7cc392bb0a8cd781f authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSun 3 Aug 2008, 23:33 (18 years ago) parented4b003
6 files changed+36−15
Main.hs+12−8 Text/Pandoc/Highlighting.hs+1−1 Text/Pandoc/ODT.hs+1−1 Text/Pandoc/Shared.hs+8−1 Text/Pandoc/TH.hs+7 pandoc.cabal+7−4
Main.hs+12−8
@@ -41,7 +41,7 @@ import System.Console.GetOpt
4141import Data.Maybe ( fromMaybe )
4242import Data.Char ( toLower )
4343import Prelude hiding ( putStrLn, writeFile, readFile, getContents )
44−#ifdef UTF_8
44+#ifdef _UTF8
4545import System.IO.UTF8
4646import System.IO ( stdout, stderr )
4747#else
@@ -54,13 +54,17 @@ copyrightMessage = "\nCopyright (C) 2006-7 John MacFarlane\n" ++
5454 "This is free software; see the source for copying conditions. There is no\n" ++
5555 "warranty, not even for merchantability or fitness for a particular purpose."
5656
57−compileOptions :: String
58−compileOptions =
57+compileInfo :: String
58+compileInfo = "Compiled" ++
59+#ifdef _UTF8
60+ " with UTF-8 support" ++
61+#else
62+ " without UTF-8 support" ++
63+#endif
5964 if null languages
60− then "\nCompiled without syntax highlighting support."
61− else "\nCompiled with syntax highlighting support for the following languages:\n" ++
62− (unlines $ map unwords $ chunk 5 $
63− map (\s -> s ++ replicate (15 - length s) ' ') languages)
65+ then " and without syntax highlighting support."
66+ else " and with syntax highlighting support for:\n" ++
67+ (unlines $ map unwords $ chunk 5 $ map (\s -> s ++ replicate (15 - length s) ' ') languages)
6468
6569-- | Splits a list into groups of at most n.
6670chunk :: Int -> [a] -> [[a]]
@@ -344,7 +348,7 @@ options =
344348 (NoArg
345349 (\_ -> do
346350 prg <- getProgName
347− hPutStrLn stderr (prg ++ " " ++ pandocVersion ++ compileOptions ++
351+ hPutStrLn stderr (prg ++ " " ++ pandocVersion ++ "\n" ++ compileInfo ++
348352 copyrightMessage)
349353 exitWith $ ExitFailure 4))
350354 "" -- "Print version"
Text/Pandoc/Highlighting.hs+1−1
@@ -32,7 +32,7 @@ Exports functions for syntax highlighting.
3232module Text.Pandoc.Highlighting ( languages, highlightHtml, defaultHighlightingCss ) where
3333import Text.XHtml
3434import Text.Pandoc.Definition
35−#ifdef HIGHLIGHTING
35+#ifdef _HIGHLIGHTING
3636import Text.Highlighting.Kate ( languages, highlightAs, formatAsXHtml, FormatOption (..), defaultHighlightingCss )
3737import Data.List (find, lookup)
3838import Data.Maybe (fromMaybe)
Text/Pandoc/ODT.hs+1−1
@@ -43,7 +43,7 @@ import Network.URI ( isURI )
4343import qualified Data.ByteString as B ( writeFile, pack )
4444import Data.ByteString.Internal ( c2w )
4545import Prelude hiding ( writeFile, readFile )
46−#ifdef UTF_8
46+#ifdef _UTF8
4747import System.IO.UTF8
4848import System.IO ( stderr )
4949#else
Text/Pandoc/Shared.hs+8−1
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-
23Copyright (C) 2006-8 John MacFarlane <jgm@berkeley.edu>
34
@@ -115,6 +116,12 @@ import Network.URI ( parseURI, URI (..), isAllowedInURI )
115116import System.FilePath ( (</>), (<.>) )
116117import System.IO.Error ( catch, ioError, isAlreadyExistsError )
117118import System.Directory
119+import Prelude hiding ( putStrLn )
120+#ifdef _UTF8
121+import System.IO.UTF8
122+#else
123+import System.IO
124+#endif
118125
119126--
120127-- List processing
@@ -612,7 +619,7 @@ readWith parser state input =
612619testStringWith :: (Show a) => GenParser Char ParserState a
613620 -> String
614621 -> IO ()
615−testStringWith parser str = putStrLn $ show $
622+testStringWith parser str = putStrLn $ show $
616623 readWith parser defaultParserState str
617624
618625-- | Parsing options.
Text/Pandoc/TH.hs+7
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# OPTIONS_GHC -fno-warn-orphans #-}
23{-
34Copyright (C) 2008 John MacFarlane <jgm@berkeley.edu>
@@ -37,6 +38,12 @@ import Language.Haskell.TH
3738import Language.Haskell.TH.Syntax (Lift (..))
3839import qualified Data.ByteString as B
3940import Data.ByteString.Internal ( w2c )
41+import Prelude hiding ( readFile )
42+#ifdef _UTF8
43+import System.IO.UTF8
44+#else
45+import System.IO
46+#endif
4047
4148-- | Insert contents of text file into a template.
4249contentsOf :: FilePath -> ExpQ
pandoc.cabal+7−4
@@ -57,7 +57,7 @@ Flag splitBase
5757 Default: True
5858Flag highlighting
5959 Description: Compile in support for syntax highlighting of code blocks.
60− Default: False
60+ Default: True
6161Flag executable
6262 Description: Build the pandoc executable.
6363 Default: True
@@ -75,10 +75,10 @@ Library
7575 Build-Depends: base < 3
7676 if flag(highlighting)
7777 Build-depends: highlighting-kate
78− cpp-options: -DHIGHLIGHTING
78+ cpp-options: -D_HIGHLIGHTING
7979 if flag(utf8)
8080 Build-depends: utf8-string
81− cpp-options: -DUTF_8
81+ cpp-options: -D_UTF8
8282 Build-Depends: parsec < 3, xhtml, mtl, network, filepath, process, directory,
8383 template-haskell, bytestring
8484 Hs-Source-Dirs: .
@@ -130,9 +130,12 @@ Executable pandoc
130130 Main-Is: Main.hs
131131 Ghc-Options: -O2 -Wall -threaded
132132 Ghc-Prof-Options: -auto-all
133+ Extensions: CPP
133134
135+ if flag(highlighting)
136+ cpp-options: -D_HIGHLIGHTING
134137 if flag(utf8)
135− cpp-options: -DUTF_8
138+ cpp-options: -D_UTF8
136139 if flag(executable)
137140 Buildable: True
138141 else