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
This commit is contained in:
fiddlosopher 2008-08-03 23:33:40 +00:00
parent ed4b003997
commit 6ff1e2a976
6 changed files with 36 additions and 15 deletions

20
Main.hs
View file

@ -41,7 +41,7 @@ import System.Console.GetOpt
import Data.Maybe ( fromMaybe )
import Data.Char ( toLower )
import Prelude hiding ( putStrLn, writeFile, readFile, getContents )
#ifdef UTF_8
#ifdef _UTF8
import System.IO.UTF8
import System.IO ( stdout, stderr )
#else
@ -54,13 +54,17 @@ copyrightMessage = "\nCopyright (C) 2006-7 John MacFarlane\n" ++
"This is free software; see the source for copying conditions. There is no\n" ++
"warranty, not even for merchantability or fitness for a particular purpose."
compileOptions :: String
compileOptions =
compileInfo :: String
compileInfo = "Compiled" ++
#ifdef _UTF8
" with UTF-8 support" ++
#else
" without UTF-8 support" ++
#endif
if null languages
then "\nCompiled without syntax highlighting support."
else "\nCompiled with syntax highlighting support for the following languages:\n" ++
(unlines $ map unwords $ chunk 5 $
map (\s -> s ++ replicate (15 - length s) ' ') languages)
then " and without syntax highlighting support."
else " and with syntax highlighting support for:\n" ++
(unlines $ map unwords $ chunk 5 $ map (\s -> s ++ replicate (15 - length s) ' ') languages)
-- | Splits a list into groups of at most n.
chunk :: Int -> [a] -> [[a]]
@ -344,7 +348,7 @@ options =
(NoArg
(\_ -> do
prg <- getProgName
hPutStrLn stderr (prg ++ " " ++ pandocVersion ++ compileOptions ++
hPutStrLn stderr (prg ++ " " ++ pandocVersion ++ "\n" ++ compileInfo ++
copyrightMessage)
exitWith $ ExitFailure 4))
"" -- "Print version"

View file

@ -32,7 +32,7 @@ Exports functions for syntax highlighting.
module Text.Pandoc.Highlighting ( languages, highlightHtml, defaultHighlightingCss ) where
import Text.XHtml
import Text.Pandoc.Definition
#ifdef HIGHLIGHTING
#ifdef _HIGHLIGHTING
import Text.Highlighting.Kate ( languages, highlightAs, formatAsXHtml, FormatOption (..), defaultHighlightingCss )
import Data.List (find, lookup)
import Data.Maybe (fromMaybe)

View file

@ -43,7 +43,7 @@ import Network.URI ( isURI )
import qualified Data.ByteString as B ( writeFile, pack )
import Data.ByteString.Internal ( c2w )
import Prelude hiding ( writeFile, readFile )
#ifdef UTF_8
#ifdef _UTF8
import System.IO.UTF8
import System.IO ( stderr )
#else

View file

@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-
Copyright (C) 2006-8 John MacFarlane <jgm@berkeley.edu>
@ -115,6 +116,12 @@ import Network.URI ( parseURI, URI (..), isAllowedInURI )
import System.FilePath ( (</>), (<.>) )
import System.IO.Error ( catch, ioError, isAlreadyExistsError )
import System.Directory
import Prelude hiding ( putStrLn )
#ifdef _UTF8
import System.IO.UTF8
#else
import System.IO
#endif
--
-- List processing
@ -612,7 +619,7 @@ readWith parser state input =
testStringWith :: (Show a) => GenParser Char ParserState a
-> String
-> IO ()
testStringWith parser str = putStrLn $ show $
testStringWith parser str = putStrLn $ show $
readWith parser defaultParserState str
-- | Parsing options.

View file

@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-
Copyright (C) 2008 John MacFarlane <jgm@berkeley.edu>
@ -37,6 +38,12 @@ import Language.Haskell.TH
import Language.Haskell.TH.Syntax (Lift (..))
import qualified Data.ByteString as B
import Data.ByteString.Internal ( w2c )
import Prelude hiding ( readFile )
#ifdef _UTF8
import System.IO.UTF8
#else
import System.IO
#endif
-- | Insert contents of text file into a template.
contentsOf :: FilePath -> ExpQ

View file

@ -57,7 +57,7 @@ Flag splitBase
Default: True
Flag highlighting
Description: Compile in support for syntax highlighting of code blocks.
Default: False
Default: True
Flag executable
Description: Build the pandoc executable.
Default: True
@ -75,10 +75,10 @@ Library
Build-Depends: base < 3
if flag(highlighting)
Build-depends: highlighting-kate
cpp-options: -DHIGHLIGHTING
cpp-options: -D_HIGHLIGHTING
if flag(utf8)
Build-depends: utf8-string
cpp-options: -DUTF_8
cpp-options: -D_UTF8
Build-Depends: parsec < 3, xhtml, mtl, network, filepath, process, directory,
template-haskell, bytestring
Hs-Source-Dirs: .
@ -130,9 +130,12 @@ Executable pandoc
Main-Is: Main.hs
Ghc-Options: -O2 -Wall -threaded
Ghc-Prof-Options: -auto-all
Extensions: CPP
if flag(highlighting)
cpp-options: -D_HIGHLIGHTING
if flag(utf8)
cpp-options: -DUTF_8
cpp-options: -D_UTF8
if flag(executable)
Buildable: True
else