From 9eb435d3c138e6ff9d057f7349a9d87d6a1975bc Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Thu, 31 Dec 2009 01:11:23 +0000 Subject: Removed TH module; refactored LaTeXMathML not to use TH. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1692 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/LaTeXMathML.hs | 18 +++++++------- src/Text/Pandoc/Shared.hs | 8 ++++++- src/Text/Pandoc/TH.hs | 53 ------------------------------------------ src/Text/Pandoc/Templates.hs | 6 ++--- src/Text/Pandoc/Writers/S5.hs | 6 +---- 5 files changed, 21 insertions(+), 70 deletions(-) delete mode 100644 src/Text/Pandoc/TH.hs (limited to 'src/Text') diff --git a/src/Text/Pandoc/LaTeXMathML.hs b/src/Text/Pandoc/LaTeXMathML.hs index 1eb3c23cc..8cdd3cd21 100644 --- a/src/Text/Pandoc/LaTeXMathML.hs +++ b/src/Text/Pandoc/LaTeXMathML.hs @@ -1,14 +1,16 @@ -{-# LANGUAGE CPP, TemplateHaskell #-} -- | Definitions for use of LaTeXMathML in HTML. -- (See ) module Text.Pandoc.LaTeXMathML ( latexMathMLScript ) where -import Text.Pandoc.TH ( contentsOf ) import System.FilePath ( () ) +import Text.Pandoc.Shared (readDataFile) -- | String containing LaTeXMathML javascript. -latexMathMLScript :: String -#ifndef __HADDOCK__ -latexMathMLScript = "\n" -#endif +latexMathMLScript :: IO String +latexMathMLScript = undefined +{- +latexMathMLScript = do + jsCom <- readDataFile $ "data" "LaTeXMathML.js.comment" + jsPacked <- readDataFile $ "data" "LaTeXMathML.js.packed" + return $ "\n" +-} diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 868edc2c7..e913d5d0b 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -104,7 +104,8 @@ module Text.Pandoc.Shared ( WriterOptions (..), defaultWriterOptions, -- * File handling - inDirectory + inDirectory, + readDataFile ) where import Text.Pandoc.Definition @@ -122,6 +123,7 @@ import System.IO.UTF8 import Data.Generics import qualified Control.Monad.State as S import Control.Monad (join) +import Paths_pandoc (getDataFileName) -- -- List processing @@ -1030,3 +1032,7 @@ inDirectory path action = do result <- action setCurrentDirectory oldDir return result + +-- | Read file from the Cabal data directory. +readDataFile :: FilePath -> IO String +readDataFile fname = getDataFileName fname >>= readFile diff --git a/src/Text/Pandoc/TH.hs b/src/Text/Pandoc/TH.hs deleted file mode 100644 index dfd6be28b..000000000 --- a/src/Text/Pandoc/TH.hs +++ /dev/null @@ -1,53 +0,0 @@ -{-# OPTIONS_GHC -fno-warn-orphans #-} -{- -Copyright (C) 2008 John MacFarlane - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --} - -{- | - Module : Text.Pandoc.TH - Copyright : Copyright (C) 2006-8 John MacFarlane - License : GNU GPL, version 2 or above - - Maintainer : John MacFarlane - Stability : alpha - Portability : portable - -Template haskell functions used by Pandoc modules. --} -module Text.Pandoc.TH ( - contentsOf, - binaryContentsOf - ) where - -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 ) -import System.IO.UTF8 - --- | Insert contents of text file into a template. -contentsOf :: FilePath -> ExpQ -contentsOf p = lift =<< (runIO $ readFile p) - --- | Insert contents of binary file into a template. --- Note that @Data.ByteString.readFile@ uses binary mode on windows. -binaryContentsOf :: FilePath -> ExpQ -binaryContentsOf p = lift =<< (runIO $ B.readFile p) - -instance Lift B.ByteString where - lift x = return (LitE (StringL $ map w2c $ B.unpack x)) diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs index 98eed7292..75989fbcd 100644 --- a/src/Text/Pandoc/Templates.hs +++ b/src/Text/Pandoc/Templates.hs @@ -52,6 +52,7 @@ import System.FilePath import System.Directory import Prelude hiding (readFile) import System.IO.UTF8 (readFile) +import Text.Pandoc.Shared (readDataFile) import Paths_pandoc -- | Get the default template, either from the application's user data @@ -73,9 +74,8 @@ getTemplateFromUserDataDirectory format = E.try $ do readFile templatePath getTemplateFromCabalDataDirectory :: String -> IO (Either E.IOException String) -getTemplateFromCabalDataDirectory format = E.try $ do - templatePath <- getDataFileName $ "templates" format <.> "template" - readFile templatePath +getTemplateFromCabalDataDirectory format = E.try $ + readDataFile $ "templates" format <.> "template" -- | Renders a template renderTemplate :: [(String,String)] -- ^ Assoc. list of values for variables diff --git a/src/Text/Pandoc/Writers/S5.hs b/src/Text/Pandoc/Writers/S5.hs index 6187bc9a8..67ff673c2 100644 --- a/src/Text/Pandoc/Writers/S5.hs +++ b/src/Text/Pandoc/Writers/S5.hs @@ -37,7 +37,7 @@ module Text.Pandoc.Writers.S5 ( writeS5String, insertS5Structure ) where -import Text.Pandoc.Shared ( WriterOptions ) +import Text.Pandoc.Shared ( WriterOptions, readDataFile ) import Text.Pandoc.Writers.HTML ( writeHtml, writeHtmlString ) import Text.Pandoc.Definition import Text.XHtml.Strict @@ -45,10 +45,6 @@ import System.FilePath ( () ) import Data.List ( intercalate ) import Prelude hiding (readFile) import System.IO.UTF8 (readFile) -import Paths_pandoc (getDataFileName) - -readDataFile :: FilePath -> IO String -readDataFile fname = getDataFileName fname >>= readFile s5HeaderIncludes :: IO String s5HeaderIncludes = do -- cgit v1.2.3