git.iko.soy/typeable/pandoc
on master help sign in
Use CPP to simplify build procedure for Highlighting.hs module.

This is no longer built by Setup.hs in the pre-configure phase. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1339 788f1e2b-df1e-0410-8736-df70ead52e1b

commit2751608d9bd59d8f23e557ed716205df8c4f503a authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 31 Jul 2008, 06:35 (18 years ago) parent57df7f5
4 files changed+15−53
Setup.hs−9 templates/Highlighting.yes.hs → Text/Pandoc/Highlighting.hs+14−2 pandoc.cabal+1 templates/Highlighting.no.hs−42
Setup.hs−9
@@ -22,14 +22,6 @@ myPostConf _ configFlags pkgDescription buildInfo = do
2222 fillAsciiMathMLTemplate
2323 fillS5WriterTemplate
2424 fillDefaultHeadersTemplate
25− let deps = packageDeps buildInfo
26− let highlighting = any (\id -> pkgName id == "highlighting-kate") deps
27− let highlightingModule = if highlighting
28− then combine "templates" "Highlighting.yes.hs"
29− else combine "templates" "Highlighting.no.hs"
30− copyFile highlightingModule $ joinPath ["Text", "Pandoc", "Highlighting.hs"]
31− putStrLn $ " Text/Pandoc/Highlighting.hs [" ++
32− (if highlighting then "with" else "without") ++ " syntax highlighting support]"
3325
3426-- Fill templateFile with data in dataFiles and write to outputFile.
3527fillTemplate :: [FilePath] -> FilePath -> FilePath -> IO ()
@@ -61,7 +53,6 @@ myPostClean _ _ _ _ = do
6153 putStrLn "Removing source files generated from templates:"
6254 removeGeneratedFile $ joinPath [pandocPath, "ASCIIMathML.hs"]
6355 removeGeneratedFile $ joinPath [pandocPath, "DefaultHeaders.hs"]
64− removeGeneratedFile $ joinPath [pandocPath, "Highlighting.hs"]
6556 removeGeneratedFile $ joinPath [pandocPath, "Writers", "S5.hs"]
6657
6758-- Remove file and print message.
templates/Highlighting.yes.hs → Text/Pandoc/Highlighting.hsrenamed+14−2
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-
23Copyright (C) 2008 John MacFarlane <jgm@berkeley.edu>
34
@@ -29,12 +30,13 @@ Exports functions for syntax highlighting.
2930-}
3031
3132module Text.Pandoc.Highlighting ( languages, highlightHtml, defaultHighlightingCss ) where
32−import Text.Highlighting.Kate ( languages, highlightAs, formatAsXHtml, FormatOption (..), defaultHighlightingCss )
3333import Text.XHtml
34+import Text.Pandoc.Definition
35+#ifdef HIGHLIGHTING
36+import Text.Highlighting.Kate ( languages, highlightAs, formatAsXHtml, FormatOption (..), defaultHighlightingCss )
3437import Data.List (find, lookup)
3538import Data.Maybe (fromMaybe)
3639import Data.Char (toLower)
37−import Text.Pandoc.Definition
3840
3941highlightHtml :: Attr -> String -> Either String Html
4042highlightHtml (_, classes, keyvals) rawCode =
@@ -50,3 +52,13 @@ highlightHtml (_, classes, keyvals) rawCode =
5052 Left err -> Left err
5153 Right hl -> Right $ formatAsXHtml fmtOpts lang hl
5254
55+#else
56+defaultHighlightingCss :: String
57+defaultHighlightingCss = ""
58+
59+languages :: [String]
60+languages = []
61+
62+highlightHtml :: Attr -> String -> Either String Html
63+highlightHtml _ _ = Left "Pandoc was not compiled with support for highlighting"
64+#endif
pandoc.cabal+1
@@ -47,6 +47,7 @@ Library
4747 Build-Depends: base < 3
4848 if flag(highlighting)
4949 Build-depends: highlighting-kate
50+ cpp-options: -DHIGHLIGHTING
5051 Build-Depends: parsec < 3, xhtml, mtl, network, filepath
5152 Hs-Source-Dirs: .
5253 Exposed-Modules: Text.Pandoc,
templates/Highlighting.no.hsdeleted−42
@@ -1,42 +0,0 @@
1−{-
2−Copyright (C) 2008 John MacFarlane <jgm@berkeley.edu>
3−
4−This program is free software; you can redistribute it and/or modify
5−it under the terms of the GNU General Public License as published by
6−the Free Software Foundation; either version 2 of the License, or
7−(at your option) any later version.
8−
9−This program is distributed in the hope that it will be useful,
10−but WITHOUT ANY WARRANTY; without even the implied warranty of
11−MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12−GNU General Public License for more details.
13−
14−You should have received a copy of the GNU General Public License
15−along with this program; if not, write to the Free Software
16−Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17−-}
18−
19−{- |
20− Module : Text.Pandoc.Highlighting
21− Copyright : Copyright (C) 2008 John MacFarlane
22− License : GNU GPL, version 2 or above
23−
24− Maintainer : John MacFarlane <jgm@berkeley.edu>
25− Stability : alpha
26− Portability : portable
27−
28−Exports functions for syntax highlighting.
29−-}
30−
31−module Text.Pandoc.Highlighting ( languages, highlightHtml, defaultHighlightingCss ) where
32−import Text.XHtml
33−import Text.Pandoc.Definition
34−
35−defaultHighlightingCss :: String
36−defaultHighlightingCss = ""
37−
38−languages :: [String]
39−languages = []
40−
41−highlightHtml :: Attr -> String -> Either String Html
42−highlightHtml _ _ = Left "Pandoc was not compiled with support for highlighting"