git.iko.soy/typeable/pandoc
on master help sign in
Removed TH module; refactored LaTeXMathML not to use TH.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1692 788f1e2b-df1e-0410-8736-df70ead52e1b

commit9eb435d3c138e6ff9d057f7349a9d87d6a1975bc authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 31 Dec 2009, 01:11 (17 years ago) parentae44c72
6 files changed+21−71
pandoc.cabal−1 src/Text/Pandoc/LaTeXMathML.hs+10−8 src/Text/Pandoc/Shared.hs+7−1 src/Text/Pandoc/TH.hs−53 src/Text/Pandoc/Templates.hs+3−3 src/Text/Pandoc/Writers/S5.hs+1−5
pandoc.cabal−1
@@ -192,7 +192,6 @@ Library
192192 Text.Pandoc.Writers.S5,
193193 Text.Pandoc.Templates
194194 Other-Modules: Text.Pandoc.XML,
195− Text.Pandoc.TH,
196195 Paths_pandoc
197196 Extensions: CPP, TemplateHaskell, FlexibleInstances
198197 Ghc-Options: -O2 -Wall
src/Text/Pandoc/LaTeXMathML.hs+10−8
@@ -1,14 +1,16 @@
1−{-# LANGUAGE CPP, TemplateHaskell #-}
21-- | Definitions for use of LaTeXMathML in HTML.
32-- (See <http://math.etsu.edu/LaTeXMathML/>)
43module Text.Pandoc.LaTeXMathML ( latexMathMLScript ) where
5−import Text.Pandoc.TH ( contentsOf )
64import System.FilePath ( (</>) )
5+import Text.Pandoc.Shared (readDataFile)
76
87-- | String containing LaTeXMathML javascript.
9−latexMathMLScript :: String
10−#ifndef __HADDOCK__
11−latexMathMLScript = "<script type=\"text/javascript\">\n" ++
12− $(contentsOf $ "data" </> "LaTeXMathML.js.comment") ++
13− $(contentsOf $ "data" </> "LaTeXMathML.js.packed") ++ "</script>\n"
14−#endif
8+latexMathMLScript :: IO String
9+latexMathMLScript = undefined
10+{-
11+latexMathMLScript = do
12+ jsCom <- readDataFile $ "data" </> "LaTeXMathML.js.comment"
13+ jsPacked <- readDataFile $ "data" </> "LaTeXMathML.js.packed"
14+ return $ "<script type=\"text/javascript\">\n" ++ jsCom ++ jsPacked ++
15+ "</script>\n"
16+-}
src/Text/Pandoc/Shared.hs+7−1
@@ -104,7 +104,8 @@ module Text.Pandoc.Shared (
104104 WriterOptions (..),
105105 defaultWriterOptions,
106106 -- * File handling
107− inDirectory
107+ inDirectory,
108+ readDataFile
108109 ) where
109110
110111import Text.Pandoc.Definition
@@ -122,6 +123,7 @@ import System.IO.UTF8
122123import Data.Generics
123124import qualified Control.Monad.State as S
124125import Control.Monad (join)
126+import Paths_pandoc (getDataFileName)
125127
126128--
127129-- List processing
@@ -1030,3 +1032,7 @@ inDirectory path action = do
10301032 result <- action
10311033 setCurrentDirectory oldDir
10321034 return result
1035+
1036+-- | Read file from the Cabal data directory.
1037+readDataFile :: FilePath -> IO String
1038+readDataFile fname = getDataFileName fname >>= readFile
src/Text/Pandoc/TH.hsdeleted−53
@@ -1,53 +0,0 @@
1−{-# OPTIONS_GHC -fno-warn-orphans #-}
2−{-
3−Copyright (C) 2008 John MacFarlane <jgm@berkeley.edu>
4−
5−This program is free software; you can redistribute it and/or modify
6−it under the terms of the GNU General Public License as published by
7−the Free Software Foundation; either version 2 of the License, or
8−(at your option) any later version.
9−
10−This program is distributed in the hope that it will be useful,
11−but WITHOUT ANY WARRANTY; without even the implied warranty of
12−MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13−GNU General Public License for more details.
14−
15−You should have received a copy of the GNU General Public License
16−along with this program; if not, write to the Free Software
17−Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18−-}
19−
20−{- |
21− Module : Text.Pandoc.TH
22− Copyright : Copyright (C) 2006-8 John MacFarlane
23− License : GNU GPL, version 2 or above
24−
25− Maintainer : John MacFarlane <jgm@berkeley.edu>
26− Stability : alpha
27− Portability : portable
28−
29−Template haskell functions used by Pandoc modules.
30−-}
31−module Text.Pandoc.TH (
32− contentsOf,
33− binaryContentsOf
34− ) where
35−
36−import Language.Haskell.TH
37−import Language.Haskell.TH.Syntax (Lift (..))
38−import qualified Data.ByteString as B
39−import Data.ByteString.Internal ( w2c )
40−import Prelude hiding ( readFile )
41−import System.IO.UTF8
42−
43−-- | Insert contents of text file into a template.
44−contentsOf :: FilePath -> ExpQ
45−contentsOf p = lift =<< (runIO $ readFile p)
46−
47−-- | Insert contents of binary file into a template.
48−-- Note that @Data.ByteString.readFile@ uses binary mode on windows.
49−binaryContentsOf :: FilePath -> ExpQ
50−binaryContentsOf p = lift =<< (runIO $ B.readFile p)
51−
52−instance Lift B.ByteString where
53− lift x = return (LitE (StringL $ map w2c $ B.unpack x))
src/Text/Pandoc/Templates.hs+3−3
@@ -52,6 +52,7 @@ import System.FilePath
5252import System.Directory
5353import Prelude hiding (readFile)
5454import System.IO.UTF8 (readFile)
55+import Text.Pandoc.Shared (readDataFile)
5556import Paths_pandoc
5657
5758-- | Get the default template, either from the application's user data
@@ -73,9 +74,8 @@ getTemplateFromUserDataDirectory format = E.try $ do
7374 readFile templatePath
7475
7576getTemplateFromCabalDataDirectory :: String -> IO (Either E.IOException String)
76−getTemplateFromCabalDataDirectory format = E.try $ do
77− templatePath <- getDataFileName $ "templates" </> format <.> "template"
78− readFile templatePath
77+getTemplateFromCabalDataDirectory format = E.try $
78+ readDataFile $ "templates" </> format <.> "template"
7979
8080-- | Renders a template
8181renderTemplate :: [(String,String)] -- ^ Assoc. list of values for variables
src/Text/Pandoc/Writers/S5.hs+1−5
@@ -37,7 +37,7 @@ module Text.Pandoc.Writers.S5 (
3737 writeS5String,
3838 insertS5Structure
3939 ) where
40−import Text.Pandoc.Shared ( WriterOptions )
40+import Text.Pandoc.Shared ( WriterOptions, readDataFile )
4141import Text.Pandoc.Writers.HTML ( writeHtml, writeHtmlString )
4242import Text.Pandoc.Definition
4343import Text.XHtml.Strict
@@ -45,10 +45,6 @@ import System.FilePath ( (</>) )
4545import Data.List ( intercalate )
4646import Prelude hiding (readFile)
4747import System.IO.UTF8 (readFile)
48−import Paths_pandoc (getDataFileName)
49−
50−readDataFile :: FilePath -> IO String
51−readDataFile fname = getDataFileName fname >>= readFile
5248
5349s5HeaderIncludes :: IO String
5450s5HeaderIncludes = do