Removed TH module; refactored LaTeXMathML not to use TH.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1692 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
fiddlosopher 2009-12-31 01:11:23 +00:00
parent ae44c7297f
commit 9eb435d3c1
6 changed files with 21 additions and 71 deletions

View file

@ -192,7 +192,6 @@ Library
Text.Pandoc.Writers.S5,
Text.Pandoc.Templates
Other-Modules: Text.Pandoc.XML,
Text.Pandoc.TH,
Paths_pandoc
Extensions: CPP, TemplateHaskell, FlexibleInstances
Ghc-Options: -O2 -Wall

View file

@ -1,14 +1,16 @@
{-# LANGUAGE CPP, TemplateHaskell #-}
-- | Definitions for use of LaTeXMathML in HTML.
-- (See <http://math.etsu.edu/LaTeXMathML/>)
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 = "<script type=\"text/javascript\">\n" ++
$(contentsOf $ "data" </> "LaTeXMathML.js.comment") ++
$(contentsOf $ "data" </> "LaTeXMathML.js.packed") ++ "</script>\n"
#endif
latexMathMLScript :: IO String
latexMathMLScript = undefined
{-
latexMathMLScript = do
jsCom <- readDataFile $ "data" </> "LaTeXMathML.js.comment"
jsPacked <- readDataFile $ "data" </> "LaTeXMathML.js.packed"
return $ "<script type=\"text/javascript\">\n" ++ jsCom ++ jsPacked ++
"</script>\n"
-}

View file

@ -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

View file

@ -1,53 +0,0 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-
Copyright (C) 2008 John MacFarlane <jgm@berkeley.edu>
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 <jgm@berkeley.edu>
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))

View file

@ -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

View file

@ -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