diff options
-rw-r--r-- | INSTALL | 4 | ||||
-rw-r--r-- | Setup.hs | 89 | ||||
-rw-r--r-- | changelog | 27 | ||||
-rw-r--r-- | man/make-pandoc-man-pages.hs (renamed from MakeManPage.hs) | 84 | ||||
-rw-r--r-- | pandoc.cabal | 138 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 6 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/EPUB.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/ODT.hs | 6 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/RTF.hs | 4 | ||||
-rw-r--r-- | src/pandoc.hs | 16 | ||||
-rw-r--r-- | tests/Tests/Arbitrary.hs (renamed from src/Tests/Arbitrary.hs) | 0 | ||||
-rw-r--r-- | tests/Tests/Helpers.hs (renamed from src/Tests/Helpers.hs) | 0 | ||||
-rw-r--r-- | tests/Tests/Old.hs (renamed from src/Tests/Old.hs) | 0 | ||||
-rw-r--r-- | tests/Tests/Readers/LaTeX.hs (renamed from src/Tests/Readers/LaTeX.hs) | 0 | ||||
-rw-r--r-- | tests/Tests/Readers/Markdown.hs (renamed from src/Tests/Readers/Markdown.hs) | 0 | ||||
-rw-r--r-- | tests/Tests/Readers/RST.hs (renamed from src/Tests/Readers/RST.hs) | 0 | ||||
-rw-r--r-- | tests/Tests/Shared.hs (renamed from src/Tests/Shared.hs) | 0 | ||||
-rw-r--r-- | tests/Tests/Writers/ConTeXt.hs (renamed from src/Tests/Writers/ConTeXt.hs) | 0 | ||||
-rw-r--r-- | tests/Tests/Writers/HTML.hs (renamed from src/Tests/Writers/HTML.hs) | 0 | ||||
-rw-r--r-- | tests/Tests/Writers/LaTeX.hs (renamed from src/Tests/Writers/LaTeX.hs) | 0 | ||||
-rw-r--r-- | tests/Tests/Writers/Markdown.hs (renamed from src/Tests/Writers/Markdown.hs) | 0 | ||||
-rw-r--r-- | tests/Tests/Writers/Native.hs (renamed from src/Tests/Writers/Native.hs) | 0 | ||||
-rw-r--r-- | tests/lhs-test.latex | 2 | ||||
-rw-r--r-- | tests/test-pandoc.hs (renamed from src/test-pandoc.hs) | 3 |
24 files changed, 176 insertions, 205 deletions
@@ -136,9 +136,9 @@ Running tests ------------- Pandoc comes with an automated test suite integrated to cabal. -To enable the tests, compile pandoc with the `tests` flag: +To enable the tests, compile pandoc with the `--enable-tests` option: - cabal install -ftests + cabal install --enable-tests Note: If you obtained the source via git, you should first do @@ -1,80 +1,43 @@ +{-# LANGUAGE ScopedTypeVariables #-} import Distribution.Simple import Distribution.Simple.Setup (copyDest, copyVerbosity, fromFlag, installVerbosity, BuildFlags(..)) -import Distribution.PackageDescription - (PackageDescription(..), Executable(..), BuildInfo(..)) +import Distribution.PackageDescription (PackageDescription(..), Executable(..)) import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..), absoluteInstallDirs) import Distribution.Verbosity ( Verbosity, silent ) -import Distribution.Simple.GHC (ghcPackageDbOptions) -import Distribution.Simple.InstallDirs (mandir, bindir, CopyDest (NoCopyDest)) +import Distribution.Simple.InstallDirs (mandir, CopyDest (NoCopyDest)) import Distribution.Simple.Utils (installOrdinaryFiles) -import Control.Exception ( bracket_ ) -import Control.Monad ( unless ) -import System.Process ( rawSystem, runCommand, waitForProcess ) +import Prelude hiding (catch) +import System.Process ( rawSystem ) import System.FilePath ( (</>) ) -import System.Directory import System.Exit -import System.Time -import System.IO.Error ( isDoesNotExistError ) -import Data.Maybe ( catMaybes ) -import Data.List ( (\\) ) main :: IO () main = do defaultMainWithHooks $ simpleUserHooks { - runTests = runTestSuite - , postBuild = makeManPages + postBuild = makeManPages , postCopy = \ _ flags pkg lbi -> installManpages pkg lbi (fromFlag $ copyVerbosity flags) (fromFlag $ copyDest flags) , postInst = \ _ flags pkg lbi -> installManpages pkg lbi (fromFlag $ installVerbosity flags) NoCopyDest + , copyHook = \pkgdescr -> + (copyHook simpleUserHooks) pkgdescr{ executables = + [x | x <- executables pkgdescr, exeName x /= "make-pandoc-man-pages"] } + , instHook = \pkgdescr -> + (instHook simpleUserHooks) pkgdescr{ executables = + [x | x <- executables pkgdescr, exeName x /= "make-pandoc-man-pages"] } } exitWith ExitSuccess --- | Run test suite. -runTestSuite :: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO a -runTestSuite args _ pkg lbi = do - let testDir = buildDir lbi </> "test-pandoc" - testDir' <- canonicalizePath testDir - let testArgs = "--timeout=5" : concatMap (\arg -> ["-t",arg]) args - if any id [buildable (buildInfo exe) | exe <- executables pkg, exeName exe == "test-pandoc"] - then inDirectory "tests" $ rawSystem (testDir' </> "test-pandoc") testArgs >>= exitWith - else do - putStrLn "Build pandoc with the 'tests' flag to run tests" - exitWith $ ExitFailure 3 - -- | Build man pages from markdown sources in man/ makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO () -makeManPages _ flags _ lbi = do - ds1 <- modifiedDependencies (manDir </> "man1" </> "pandoc.1") - ["README", manDir </> "man1" </> "pandoc.1.template"] - ds2 <- modifiedDependencies (manDir </> "man5" </> "pandoc_markdown.5") - ["README", manDir </> "man5" </> "pandoc_markdown.5.template"] - - let distPref = fromFlag (buildDistPref flags) - packageDB = - withPackageDB lbi - ++ [SpecificPackageDB $ distPref </> "package.conf.inplace"] - - verbosity = fromFlag $ buildVerbosity flags - - args = makeGhcArgs (ghcPackageDbOptions packageDB) - ++ ["MakeManPage.hs"] - args' = if verbosity == silent - then args - else args ++ ["--verbose"] - -- Don't run MakeManPage.hs unless we have to - unless (null ds1 && null ds2) $ do - rawSystem "runghc" args' >>= exitWith - --- format arguments to runghc that we wish to pass to ghc --- normally runghc gets it right, unless the argument does --- not begin with a '-' charecter, so we need to give clear --- directions. -makeGhcArgs :: [String] -> [String] -makeGhcArgs = map ("--ghc-arg="++) +makeManPages _ flags _ _ = do + let verbosity = fromFlag $ buildVerbosity flags + let args = ["--verbose" | verbosity /= silent] + rawSystem ("dist" </> "build" </> "make-pandoc-man-pages" </> "make-pandoc-man-pages") + args >>= exitWith manpages :: [FilePath] manpages = ["man1" </> "pandoc.1" @@ -88,21 +51,3 @@ installManpages :: PackageDescription -> LocalBuildInfo installManpages pkg lbi verbosity copy = installOrdinaryFiles verbosity (mandir (absoluteInstallDirs pkg lbi copy)) (zip (repeat manDir) manpages) - --- | Returns a list of 'dependencies' that have been modified after 'file'. -modifiedDependencies :: FilePath -> [FilePath] -> IO [FilePath] -modifiedDependencies file dependencies = do - fileModTime <- catch (getModificationTime file) $ - \e -> if isDoesNotExistError e - then return (TOD 0 0) -- the minimum ClockTime - else ioError e - depModTimes <- mapM getModificationTime dependencies - let modified = zipWith (\dep time -> if time > fileModTime then Just dep else Nothing) dependencies depModTimes - return $ catMaybes modified - --- | Perform an IO action in a directory. -inDirectory :: FilePath -> IO a -> IO a -inDirectory dir action = do - oldDir <- getCurrentDirectory - bracket_ (setCurrentDirectory dir) (setCurrentDirectory oldDir) action - @@ -1,3 +1,30 @@ +pandoc (1.9.4.5) + + * Raised version bounds on network, base64-bytestring, json, + and template-haskell. + +pandoc (1.9.4.4) + + * Removed `tests` flag and made test suite into a proper cabal + test suite, which can now be enabled using `--enable-tests` + and run with `cabal test`. + + * Moved man page creation out of `Setup.hs` and into an + executable built by Cabal, but never installed. This + allows dependencies to be specified, and solves a problem + with 1.9.4.3, which could only be installed if `data-default` + had already been installed. + + * Updated `lhs-latex.tex` test for latest highlighting-kate + representation of backticks. + +pandoc (1.9.4.3) + + * Removed `-threaded` from default compile flags. + + * Modified modules to compile with GHC 7.6 and latest version of time + package. + pandoc (1.9.4.2) * Don't encode/decode file paths if base >= 4.4. diff --git a/MakeManPage.hs b/man/make-pandoc-man-pages.hs index 8405df70b..cfefa7aa3 100644 --- a/MakeManPage.hs +++ b/man/make-pandoc-man-pages.hs @@ -1,59 +1,55 @@ -- Create pandoc.1 man and pandoc_markdown.5 man pages from README import Text.Pandoc -import Data.ByteString.UTF8 (toString, fromString) +import qualified Text.Pandoc.UTF8 as UTF8 import Data.Char (toUpper) -import qualified Data.ByteString as B import Control.Monad import System.FilePath import System.Environment (getArgs) import Text.Pandoc.Shared (normalize) -import System.Directory (getModificationTime) -import System.IO.Error (isDoesNotExistError) +import Data.Maybe ( catMaybes ) +import Data.Time.Clock (UTCTime(..)) +import Prelude hiding (catch) +import Control.Exception ( catch ) +import System.IO.Error ( isDoesNotExistError ) import System.Time (ClockTime(..)) -import Data.Maybe (catMaybes) +import System.Directory +main :: IO () main = do - rmContents <- liftM toString $ B.readFile "README" - let (Pandoc meta blocks) = readMarkdown defaultParserState rmContents - let manBlocks = removeSect [Str "Wrappers"] - $ removeSect [Str "Pandoc's",Space,Str "markdown"] blocks - let syntaxBlocks = extractSect [Str "Pandoc's",Space,Str "markdown"] blocks - args <- getArgs - let verbose = "--verbose" `elem` args - makeManPage verbose ("man" </> "man1" </> "pandoc.1") - meta manBlocks - makeManPage verbose ("man" </> "man5" </> "pandoc_markdown.5") - meta syntaxBlocks + ds1 <- modifiedDependencies ("man" </> "man1" </> "pandoc.1") + ["README", "man" </> "man1" </> "pandoc.1.template"] + ds2 <- modifiedDependencies ("man" </> "man5" </> "pandoc_markdown.5") + ["README", "man" </> "man5" </> "pandoc_markdown.5.template"] + + unless (null ds1 && null ds2) $ do + rmContents <- UTF8.readFile "README" + let (Pandoc meta blocks) = readMarkdown defaultParserState rmContents + let manBlocks = removeSect [Str "Wrappers"] + $ removeSect [Str "Pandoc's",Space,Str "markdown"] blocks + let syntaxBlocks = extractSect [Str "Pandoc's",Space,Str "markdown"] blocks + args <- getArgs + let verbose = "--verbose" `elem` args + unless (null ds1) $ + makeManPage verbose ("man" </> "man1" </> "pandoc.1") meta manBlocks + unless (null ds2) $ + makeManPage verbose ("man" </> "man5" </> "pandoc_markdown.5") meta syntaxBlocks makeManPage :: Bool -> FilePath -> Meta -> [Block] -> IO () makeManPage verbose page meta blocks = do let templ = page <.> "template" - modDeps <- modifiedDependencies page ["README", templ] - unless (null modDeps) $ do - manTemplate <- liftM toString $ B.readFile templ - writeManPage page manTemplate (Pandoc meta blocks) - when verbose $ - putStrLn $ "Created " ++ page + manTemplate <- UTF8.readFile templ + writeManPage page manTemplate (Pandoc meta blocks) + when verbose $ putStrLn $ "Created " ++ page writeManPage :: FilePath -> String -> Pandoc -> IO () writeManPage page templ doc = do - let opts = defaultWriterOptions{ writerStandalone = True - , writerTemplate = templ } + let opts = defaultWriterOptions{ + writerStandalone = True + , writerTemplate = templ } let manPage = writeMan opts $ bottomUp (concatMap removeLinks) $ bottomUp capitalizeHeaders doc - B.writeFile page $ fromString manPage - --- | Returns a list of 'dependencies' that have been modified after 'file'. -modifiedDependencies :: FilePath -> [FilePath] -> IO [FilePath] -modifiedDependencies file dependencies = do - fileModTime <- catch (getModificationTime file) $ - \e -> if isDoesNotExistError e - then return (TOD 0 0) -- the minimum ClockTime - else ioError e - depModTimes <- mapM getModificationTime dependencies - let modified = zipWith (\dep time -> if time > fileModTime then Just dep else Nothing) dependencies depModTimes - return $ catMaybes modified + UTF8.writeFile page manPage removeLinks :: Inline -> [Inline] removeLinks (Link l _) = l @@ -85,3 +81,19 @@ isHeader1 :: Block -> Bool isHeader1 (Header 1 _) = True isHeader1 _ = False + +-- | Returns a list of 'dependencies' that have been modified after 'file'. +modifiedDependencies :: FilePath -> [FilePath] -> IO [FilePath] +modifiedDependencies file dependencies = do + fileModTime <- catch (getModificationTime file) $ + \e -> if isDoesNotExistError e +#if MIN_VERSION_directory(1,2,0) + then return (UTCTime (toEnum 0) 0) -- the minimum ClockTime +#else + then return (TOD 0 0) -- the minimum ClockTime +#endif + else ioError e + depModTimes <- mapM getModificationTime dependencies + let modified = zipWith (\dep time -> if time > fileModTime then Just dep else Nothing) dependencies depModTimes + return $ catMaybes modified + diff --git a/pandoc.cabal b/pandoc.cabal index b4c74125f..101a040bf 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -1,5 +1,5 @@ Name: pandoc -Version: 1.9.4.2 +Version: 1.9.4.5 Cabal-Version: >= 1.10 Build-Type: Custom License: GPL @@ -90,7 +90,6 @@ Data-Files: README, INSTALL, COPYRIGHT, BUGS, changelog Extra-Source-Files: -- code to create pandoc.1 man page - MakeManPage.hs, man/man1/pandoc.1.template, man/man5/pandoc_markdown.5.template, -- generated man pages (produced post-build) @@ -188,9 +187,6 @@ Flag executable Flag library Description: Build the pandoc library. Default: True -Flag tests - Description: Build test-pandoc. - Default: False Flag blaze_html_0_5 Description: Use blaze-html 0.5 and blaze-markup 0.5 Default: False @@ -199,13 +195,13 @@ Library -- Note: the following is duplicated in all stanzas. -- It needs to be duplicated because of the library & executable flags. -- BEGIN DUPLICATED SECTION - Build-Depends: containers >= 0.1 && < 0.5, + Build-Depends: containers >= 0.1 && < 0.6, parsec >= 3.1 && < 3.2, mtl >= 1.1 && < 2.2, - network >= 2 && < 2.4, + network >= 2 && < 2.5, filepath >= 1.1 && < 1.4, process >= 1 && < 1.2, - directory >= 1 && < 1.2, + directory >= 1 && < 1.3, bytestring >= 0.9 && < 1.0, zip-archive >= 0.1.1.7 && < 0.2, utf8-string >= 0.3 && < 0.4, @@ -218,9 +214,9 @@ Library extensible-exceptions >= 0.1 && < 0.2, citeproc-hs >= 0.3.4 && < 0.4, pandoc-types >= 1.9.0.2 && < 1.10, - json >= 0.4 && < 0.6, + json >= 0.4 && < 0.8, tagsoup >= 0.12.5 && < 0.13, - base64-bytestring >= 0.1 && < 0.2, + base64-bytestring >= 0.1 && < 1.1, zlib >= 0.5 && < 0.6, highlighting-kate >= 0.5.1 && < 0.6, temporary >= 1.1 && < 1.2 @@ -289,9 +285,9 @@ Library Text.Pandoc.PDF, Text.Pandoc.Templates, Text.Pandoc.Biblio, + Text.Pandoc.UTF8, Text.Pandoc.SelfContained Other-Modules: Text.Pandoc.XML, - Text.Pandoc.UTF8, Text.Pandoc.MIME, Text.Pandoc.UUID, Text.Pandoc.ImageSize, @@ -307,13 +303,13 @@ Executable pandoc -- Note: the following is duplicated in all stanzas. -- It needs to be duplicated because of the library & executable flags. -- BEGIN DUPLICATED SECTION - Build-Depends: containers >= 0.1 && < 0.5, + Build-Depends: containers >= 0.1 && < 0.6, parsec >= 3.1 && < 3.2, mtl >= 1.1 && < 2.2, - network >= 2 && < 2.4, + network >= 2 && < 2.5, filepath >= 1.1 && < 1.4, process >= 1 && < 1.2, - directory >= 1 && < 1.2, + directory >= 1 && < 1.3, bytestring >= 0.9 && < 1.0, zip-archive >= 0.1.1.7 && < 0.2, utf8-string >= 0.3 && < 0.4, @@ -326,9 +322,9 @@ Executable pandoc extensible-exceptions >= 0.1 && < 0.2, citeproc-hs >= 0.3.4 && < 0.4, pandoc-types >= 1.9.0.2 && < 1.10, - json >= 0.4 && < 0.6, + json >= 0.4 && < 0.8, tagsoup >= 0.12.5 && < 0.13, - base64-bytestring >= 0.1 && < 0.2, + base64-bytestring >= 0.1 && < 1.1, zlib >= 0.5 && < 0.6, highlighting-kate >= 0.5.1 && < 0.6, temporary >= 1.1 && < 1.2 @@ -369,43 +365,23 @@ Executable pandoc else Buildable: False -Executable test-pandoc - Main-Is: test-pandoc.hs - -- Note: the following is duplicated in all stanzas. - -- It needs to be duplicated because of the library & executable flags. - -- BEGIN DUPLICATED SECTION - Build-Depends: containers >= 0.1 && < 0.5, - parsec >= 3.1 && < 3.2, - mtl >= 1.1 && < 2.2, - network >= 2 && < 2.4, +-- NOTE: A trick in Setup.hs makes sure this won't be installed: +Executable make-pandoc-man-pages + Main-Is: make-pandoc-man-pages.hs + Hs-Source-Dirs: man + Build-Depends: base >= 4.2 && < 5, + pandoc, + directory >= 1 && < 1.3, filepath >= 1.1 && < 1.4, - process >= 1 && < 1.2, - directory >= 1 && < 1.2, - bytestring >= 0.9 && < 1.0, - zip-archive >= 0.1.1.7 && < 0.2, - utf8-string >= 0.3 && < 0.4, - old-locale >= 1 && < 1.1, - time >= 1.2 && < 1.5, - HTTP >= 4000.0.5 && < 4000.3, - texmath >= 0.6.0.2 && < 0.7, - xml >= 1.3.12 && < 1.4, - random >= 1 && < 1.1, - extensible-exceptions >= 0.1 && < 0.2, - citeproc-hs >= 0.3.4 && < 0.4, - pandoc-types >= 1.9.0.2 && < 1.10, - json >= 0.4 && < 0.6, - tagsoup >= 0.12.5 && < 0.13, - base64-bytestring >= 0.1 && < 0.2, - zlib >= 0.5 && < 0.6, - highlighting-kate >= 0.5.1 && < 0.6, - temporary >= 1.1 && < 1.2 - if flag(blaze_html_0_5) - build-depends: - blaze-html >= 0.5 && < 0.6, - blaze-markup >= 0.5.1 && < 0.6 - else - build-depends: - blaze-html >= 0.4.3.0 && < 0.5 + old-time >= 1.1 && < 1.2, + time >= 1.2 && < 1.5 + Default-Language: Haskell98 + Default-Extensions: CPP + +Test-Suite test-pandoc + Type: exitcode-stdio-1.0 + Main-Is: test-pandoc.hs + Hs-Source-Dirs: tests if impl(ghc >= 6.10) Build-depends: base >= 4 && < 5, syb >= 0.1 && < 0.4 else @@ -427,33 +403,33 @@ Executable test-pandoc ScopedTypeVariables, GeneralizedNewtypeDeriving, RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances, FlexibleInstances - Hs-Source-Dirs: src - -- END DUPLICATED SECTION - if !flag(tests) - Buildable: False + if impl(ghc >= 7) + cpp-options: -D_LIT=lit else - Buildable: True - if impl(ghc >= 7) - cpp-options: -D_LIT=lit - else - cpp-options: -D_LIT=$lit - Other-Extensions: TemplateHaskell, QuasiQuotes - Build-Depends: Diff, test-framework >= 0.3 && < 0.7, - test-framework-hunit >= 0.2 && < 0.3, - test-framework-quickcheck2 >= 0.2.9 && < 0.3, - QuickCheck >= 2.4 && < 2.6, - HUnit >= 1.2 && < 1.3, - template-haskell >= 2.4 && < 2.8, - ansi-terminal == 0.5.* - Other-Modules: Tests.Old - Tests.Helpers - Tests.Arbitrary - Tests.Shared - Tests.Readers.LaTeX - Tests.Readers.Markdown - Tests.Readers.RST - Tests.Writers.Native - Tests.Writers.ConTeXt - Tests.Writers.HTML - Tests.Writers.Markdown - Tests.Writers.LaTeX + cpp-options: -D_LIT=$lit + Other-Extensions: TemplateHaskell, QuasiQuotes + Build-Depends: pandoc, Diff, test-framework >= 0.3 && < 0.7, + pandoc-types >= 1.9.0.2 && < 1.10, + test-framework-hunit >= 0.2 && < 0.3, + test-framework-quickcheck2 >= 0.2.9 && < 0.3, + process >= 1 && < 1.2, + filepath >= 1.1 && < 1.4, + directory >= 1 && < 1.3, + bytestring >= 0.9 && < 1.0, + utf8-string >= 0.3 && < 0.4, + QuickCheck >= 2.4 && < 2.6, + HUnit >= 1.2 && < 1.3, + template-haskell >= 2.4 && < 2.9, + ansi-terminal == 0.5.* + Other-Modules: Tests.Old + Tests.Helpers + Tests.Arbitrary + Tests.Shared + Tests.Readers.LaTeX + Tests.Readers.Markdown + Tests.Readers.RST + Tests.Writers.Native + Tests.Writers.ConTeXt + Tests.Writers.HTML + Tests.Writers.Markdown + Tests.Writers.LaTeX diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 3178945e4..37f34e853 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Conversion of LaTeX to 'Pandoc' document. -} +{-# LANGUAGE ScopedTypeVariables #-} module Text.Pandoc.Readers.LaTeX ( readLaTeX, rawLaTeXInline, rawLaTeXBlock, @@ -47,6 +48,7 @@ import Data.Monoid import System.FilePath (replaceExtension) import Data.List (intercalate) import qualified Data.Map as M +import qualified Control.Exception as E (catch, IOException) -- | Parse LaTeX from string and return 'Pandoc' document. readLaTeX :: ParserState -- ^ Parser state, including options for parser @@ -671,8 +673,8 @@ handleIncludes :: String -> IO String handleIncludes [] = return [] handleIncludes ('\\':xs) = case runParser include defaultParserState "input" ('\\':xs) of - Right (fs, rest) -> do let getfile f = catch (UTF8.readFile f) - (\_ -> return "") + Right (fs, rest) -> do let getfile f = E.catch (UTF8.readFile f) + (\(_::E.IOException) -> return "") yss <- mapM getfile fs (intercalate "\n" yss ++) `fmap` handleIncludes rest diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index b423f136f..d1cd67c68 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -48,7 +48,9 @@ import Text.Pandoc.Writers.Markdown ( writePlain ) import Data.Char ( toLower ) import Network.URI ( unEscapeString ) import Text.Pandoc.MIME (getMimeType) +#if ! MIN_VERSION_base(4,6,0) import Prelude hiding (catch) +#endif import Control.Exception (catch, SomeException) -- | Produce an EPUB file from a Pandoc document. diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs index f8f22494f..6f5387691 100644 --- a/src/Text/Pandoc/Writers/ODT.hs +++ b/src/Text/Pandoc/Writers/ODT.hs @@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Conversion of 'Pandoc' documents to ODT. -} +{-# LANGUAGE ScopedTypeVariables #-} module Text.Pandoc.Writers.ODT ( writeODT ) where import Data.IORef import Data.List ( isPrefixOf ) @@ -47,6 +48,7 @@ import Control.Monad (liftM) import Network.URI ( unEscapeString ) import Text.Pandoc.XML import Text.Pandoc.Pretty +import qualified Control.Exception as E (catch, IOException) -- | Produce an ODT file from a Pandoc document. writeODT :: Maybe FilePath -- ^ Path specified by --reference-odt @@ -110,9 +112,9 @@ transformPic sourceDir entriesRef (Image lab (src,tit)) = do Nothing -> tit entries <- readIORef entriesRef let newsrc = "Pictures/" ++ show (length entries) ++ takeExtension src' - catch (readEntry [] (sourceDir </> src') >>= \entry -> + E.catch (readEntry [] (sourceDir </> src') >>= \entry -> modifyIORef entriesRef (entry{ eRelativePath = newsrc } :) >> return (Image lab (newsrc, tit'))) - (\_ -> return (Emph lab)) + (\(_::E.IOException) -> return (Emph lab)) transformPic _ _ x = return x diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs index 4e7c2a7cd..91df240af 100644 --- a/src/Text/Pandoc/Writers/RTF.hs +++ b/src/Text/Pandoc/Writers/RTF.hs @@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Conversion of 'Pandoc' documents to RTF (rich text format). -} +{-# LANGUAGE ScopedTypeVariables #-} module Text.Pandoc.Writers.RTF ( writeRTF, rtfEmbedImage ) where import Text.Pandoc.Definition import Text.Pandoc.Shared @@ -38,6 +39,7 @@ import System.FilePath ( takeExtension ) import qualified Data.ByteString as B import Text.Printf ( printf ) import Network.URI ( isAbsoluteURI, unEscapeString ) +import qualified Control.Exception as E (catch, IOException) -- | Convert Image inlines into a raw RTF embedded image, read from a file. -- If file not found or filetype not jpeg or png, leave the inline unchanged. @@ -47,7 +49,7 @@ rtfEmbedImage x@(Image _ (src,_)) = do if ext `elem` [".jpg",".jpeg",".png"] && not (isAbsoluteURI src) then do let src' = unEscapeString src - imgdata <- catch (B.readFile src') (\_ -> return B.empty) + imgdata <- E.catch (B.readFile src') (\(_::E.IOException) -> return B.empty) let bytes = map (printf "%02x") $ B.unpack imgdata let filetype = case ext of ".jpg" -> "\\jpegblip" diff --git a/src/pandoc.hs b/src/pandoc.hs index 0eb64c9ba..77510c906 100644 --- a/src/pandoc.hs +++ b/src/pandoc.hs @@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Parses command-line options and calls the appropriate readers and writers. -} +{-# LANGUAGE ScopedTypeVariables #-} module Main where import Text.Pandoc import Text.Pandoc.PDF (tex2pdf) @@ -62,6 +63,7 @@ import Text.CSL.Reference (Reference(..)) #else import Codec.Binary.UTF8.String (decodeString, encodeString) #endif +import qualified Control.Exception as E (catch, IOException) encodePath, decodeArg :: FilePath -> FilePath #if MIN_VERSION_base(4,4,0) @@ -837,9 +839,9 @@ main = do let sources = if ignoreArgs then [] else args datadir <- case mbDataDir of - Nothing -> catch + Nothing -> E.catch (liftM Just $ getAppUserDataDirectory "pandoc") - (const $ return Nothing) + (\(_::E.IOException) -> return Nothing) Just _ -> return mbDataDir -- assign reader and writer based on options and filenames @@ -890,12 +892,12 @@ main = do let tp' = case takeExtension tp of "" -> tp <.> format _ -> tp - catch (UTF8.readFile tp') - (\e -> if isDoesNotExistError e - then catch + E.catch (UTF8.readFile tp') + (\(e::E.IOException) -> if isDoesNotExistError e + then E.catch (readDataFile datadir $ "templates" </> tp') - (\_ -> throwIO e) + (\(_::E.IOException) -> throwIO e) else throwIO e) let slideVariant = case writerName' of @@ -926,7 +928,7 @@ main = do -- that we can do lookups with regular string equality let unescapeRefId ref = ref{ refId = fromEntities (refId ref) } - refs <- mapM (\f -> catch (CSL.readBiblioFile f) $ \e -> + refs <- mapM (\f -> E.catch (CSL.readBiblioFile f) $ \(e::E.IOException) -> err 23 $ "Error reading bibliography `" ++ f ++ "'" ++ "\n" ++ show e) reffiles >>= return . map unescapeRefId . concat diff --git a/src/Tests/Arbitrary.hs b/tests/Tests/Arbitrary.hs index 9d65e1f1f..9d65e1f1f 100644 --- a/src/Tests/Arbitrary.hs +++ b/tests/Tests/Arbitrary.hs diff --git a/src/Tests/Helpers.hs b/tests/Tests/Helpers.hs index 66879efed..66879efed 100644 --- a/src/Tests/Helpers.hs +++ b/tests/Tests/Helpers.hs diff --git a/src/Tests/Old.hs b/tests/Tests/Old.hs index 67eb51573..67eb51573 100644 --- a/src/Tests/Old.hs +++ b/tests/Tests/Old.hs diff --git a/src/Tests/Readers/LaTeX.hs b/tests/Tests/Readers/LaTeX.hs index d60026b20..d60026b20 100644 --- a/src/Tests/Readers/LaTeX.hs +++ b/tests/Tests/Readers/LaTeX.hs diff --git a/src/Tests/Readers/Markdown.hs b/tests/Tests/Readers/Markdown.hs index 5ad974adf..5ad974adf 100644 --- a/src/Tests/Readers/Markdown.hs +++ b/tests/Tests/Readers/Markdown.hs diff --git a/src/Tests/Readers/RST.hs b/tests/Tests/Readers/RST.hs index 3269092a6..3269092a6 100644 --- a/src/Tests/Readers/RST.hs +++ b/tests/Tests/Readers/RST.hs diff --git a/src/Tests/Shared.hs b/tests/Tests/Shared.hs index f4bf13da4..f4bf13da4 100644 --- a/src/Tests/Shared.hs +++ b/tests/Tests/Shared.hs diff --git a/src/Tests/Writers/ConTeXt.hs b/tests/Tests/Writers/ConTeXt.hs index beb6411f0..beb6411f0 100644 --- a/src/Tests/Writers/ConTeXt.hs +++ b/tests/Tests/Writers/ConTeXt.hs diff --git a/src/Tests/Writers/HTML.hs b/tests/Tests/Writers/HTML.hs index 8561aa421..8561aa421 100644 --- a/src/Tests/Writers/HTML.hs +++ b/tests/Tests/Writers/HTML.hs diff --git a/src/Tests/Writers/LaTeX.hs b/tests/Tests/Writers/LaTeX.hs index 7987716f3..7987716f3 100644 --- a/src/Tests/Writers/LaTeX.hs +++ b/tests/Tests/Writers/LaTeX.hs diff --git a/src/Tests/Writers/Markdown.hs b/tests/Tests/Writers/Markdown.hs index d90dc83b1..d90dc83b1 100644 --- a/src/Tests/Writers/Markdown.hs +++ b/tests/Tests/Writers/Markdown.hs diff --git a/src/Tests/Writers/Native.hs b/tests/Tests/Writers/Native.hs index 19740e0f4..19740e0f4 100644 --- a/src/Tests/Writers/Native.hs +++ b/tests/Tests/Writers/Native.hs diff --git a/tests/lhs-test.latex b/tests/lhs-test.latex index d2d1f9ab8..acfb86679 100644 --- a/tests/lhs-test.latex +++ b/tests/lhs-test.latex @@ -70,7 +70,7 @@ return a single value: \begin{Highlighting}[] \OtherTok{unsplit ::} \NormalTok{(}\DataTypeTok{Arrow} \NormalTok{a) }\OtherTok{=>} \NormalTok{(b }\OtherTok{->} \NormalTok{c }\OtherTok{->} \NormalTok{d) }\OtherTok{->} \NormalTok{a (b, c) d} \NormalTok{unsplit }\FunctionTok{=} \NormalTok{arr }\FunctionTok{.} \FunctionTok{uncurry} - \CommentTok{-- arr (\textbackslash{}op (x,y) -> x `op` y) } + \CommentTok{-- arr (\textbackslash{}op (x,y) -> x {\char18}op{\char18} y) } \end{Highlighting} \end{Shaded} diff --git a/src/test-pandoc.hs b/tests/test-pandoc.hs index 1a8c05e14..968f31df6 100644 --- a/src/test-pandoc.hs +++ b/tests/test-pandoc.hs @@ -14,6 +14,7 @@ import qualified Tests.Writers.HTML import qualified Tests.Writers.Native import qualified Tests.Writers.Markdown import qualified Tests.Shared +import Text.Pandoc.Shared (inDirectory) tests :: [Test] tests = [ testGroup "Old" Tests.Old.tests @@ -33,4 +34,4 @@ tests = [ testGroup "Old" Tests.Old.tests ] main :: IO () -main = defaultMain tests +main = inDirectory "tests" $ defaultMain tests |