summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--INSTALL2
-rw-r--r--Setup.hs17
-rw-r--r--pandoc.cabal2
3 files changed, 19 insertions, 2 deletions
diff --git a/INSTALL b/INSTALL
index 9156356ca..4f20c9d67 100644
--- a/INSTALL
+++ b/INSTALL
@@ -119,7 +119,7 @@ assume that the pandoc source directory is your working directory.
- `embed_data_files`: embed all data files into the binary (default no).
This is helpful if you want to create a relocatable binary.
Note: if this option is selected, you need to install the
- `hsb2hs` preprocessor: `cabal install hsb2hs` (version 0.3 or
+ `hsb2hs` preprocessor: `cabal install hsb2hs` (version 0.3.1 or
higher is required).
- `https`: enable support for downloading resources over https
diff --git a/Setup.hs b/Setup.hs
index c28e45fdd..a328c75a7 100644
--- a/Setup.hs
+++ b/Setup.hs
@@ -23,18 +23,35 @@ import Distribution.PackageDescription (PackageDescription(..), FlagName(..))
import System.Process ( rawSystem )
import System.FilePath ( (</>) )
import System.Directory ( findExecutable )
+import Distribution.Verbosity ( Verbosity )
import Distribution.Simple.Utils (info, notice, installOrdinaryFiles)
import Distribution.Simple.Setup
+import Distribution.Simple.Program (simpleProgram, Program(..))
import Distribution.Simple.LocalBuildInfo
+import Data.Version
+import System.Process (readProcess)
+import Text.ParserCombinators.ReadP (readP_to_S, skipSpaces, eof)
import Control.Monad (when)
main :: IO ()
main = defaultMainWithHooks $ simpleUserHooks {
-- enable hsb2hs preprocessor for .hsb files
hookedPreProcessors = [ppBlobSuffixHandler]
+ , hookedPrograms = [(simpleProgram "hsb2hs"){
+ programFindVersion = findHsb2hsVersion }]
, postCopy = installManPage
}
+findHsb2hsVersion :: Verbosity -> FilePath -> IO (Maybe Version)
+findHsb2hsVersion verb fp = do
+ outp <- readProcess fp ["--version"] ""
+ case readP_to_S (do v <- parseVersion
+ skipSpaces
+ eof
+ return v) outp of
+ ((v,""):_) -> return (Just v)
+ _ -> return Nothing
+
ppBlobSuffixHandler :: PPSuffixHandler
ppBlobSuffixHandler = ("hsb", \_ lbi ->
PreProcessor {
diff --git a/pandoc.cabal b/pandoc.cabal
index 34d026827..9045647df 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -292,7 +292,7 @@ Library
cpp-options: -DHTTP_CLIENT
if flag(embed_data_files)
cpp-options: -DEMBED_DATA_FILES
- -- Build-Tools: hsb2hs -- not yet recognized by cabal
+ Build-Tools: hsb2hs >= 0.3.1
other-modules: Text.Pandoc.Data
if os(windows)
Cpp-options: -D_WINDOWS