git.iko.soy/typeable/pandoc
on master help sign in
Removed TH module; refactored LaTeXMathML not to use TH.
9eb435dfiddlosopher
pandoc.cabal−1
@@ -192,7 +192,6 @@ Library
192 Text.Pandoc.Writers.S5,
192 Text.Pandoc.Writers.S5,
193 Text.Pandoc.Templates
193 Text.Pandoc.Templates
194 Other-Modules: Text.Pandoc.XML,
194 Other-Modules: Text.Pandoc.XML,
195− Text.Pandoc.TH,
196 Paths_pandoc
195 Paths_pandoc
197 Extensions: CPP, TemplateHaskell, FlexibleInstances
196 Extensions: CPP, TemplateHaskell, FlexibleInstances
198 Ghc-Options: -O2 -Wall
197 Ghc-Options: -O2 -Wall
src/Text/Pandoc/LaTeXMathML.hs+10−8
@@ -1,14 +1,16 @@
1−{-# LANGUAGE CPP, TemplateHaskell #-}
2-- | Definitions for use of LaTeXMathML in HTML.
1-- | Definitions for use of LaTeXMathML in HTML.
3-- (See <http://math.etsu.edu/LaTeXMathML/>)
2-- (See <http://math.etsu.edu/LaTeXMathML/>)
4module Text.Pandoc.LaTeXMathML ( latexMathMLScript ) where
3module Text.Pandoc.LaTeXMathML ( latexMathMLScript ) where
5−import Text.Pandoc.TH ( contentsOf )
6import System.FilePath ( (</>) )
4import System.FilePath ( (</>) )
5+import Text.Pandoc.Shared (readDataFile)
7
6
8-- | String containing LaTeXMathML javascript.
7-- | String containing LaTeXMathML javascript.
9−latexMathMLScript :: String
8+latexMathMLScript :: IO String
10−#ifndef __HADDOCK__
9+latexMathMLScript = undefined
10+{-
11+latexMathMLScript = do
12+ jsCom <- readDataFile $ "data" </> "LaTeXMathML.js.comment"
13+ jsPacked <- readDataFile $ "data" </> "LaTeXMathML.js.packed"
11−latexMathMLScript = "<script type=\"text/javascript\">\n" ++
14+ return $ "<script type=\"text/javascript\">\n" ++ jsCom ++ jsPacked ++
12− $(contentsOf $ "data" </> "LaTeXMathML.js.comment") ++
15+ "</script>\n"
13− $(contentsOf $ "data" </> "LaTeXMathML.js.packed") ++ "</script>\n"
16+-}
14−#endif
src/Text/Pandoc/Shared.hs+7−1
@@ -104,7 +104,8 @@ module Text.Pandoc.Shared (
104 WriterOptions (..),
104 WriterOptions (..),
105 defaultWriterOptions,
105 defaultWriterOptions,
106 -- * File handling
106 -- * File handling
107− inDirectory
107+ inDirectory,
108+ readDataFile
108 ) where
109 ) where
109
110
110import Text.Pandoc.Definition
111import Text.Pandoc.Definition
@@ -122,6 +123,7 @@ import System.IO.UTF8
122import Data.Generics
123import Data.Generics
123import qualified Control.Monad.State as S
124import qualified Control.Monad.State as S
124import Control.Monad (join)
125import Control.Monad (join)
126+import Paths_pandoc (getDataFileName)
125
127
126--
128--
127-- List processing
129-- List processing
@@ -1030,3 +1032,7 @@ inDirectory path action = do
1030 result <- action
1032 result <- action
1031 setCurrentDirectory oldDir
1033 setCurrentDirectory oldDir
1032 return result
1034 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
52import System.Directory
52import System.Directory
53import Prelude hiding (readFile)
53import Prelude hiding (readFile)
54import System.IO.UTF8 (readFile)
54import System.IO.UTF8 (readFile)
55+import Text.Pandoc.Shared (readDataFile)
55import Paths_pandoc
56import Paths_pandoc
56
57
57-- | Get the default template, either from the application's user data
58-- | Get the default template, either from the application's user data
@@ -73,9 +74,8 @@ getTemplateFromUserDataDirectory format = E.try $ do
73 readFile templatePath
74 readFile templatePath
74
75
75getTemplateFromCabalDataDirectory :: String -> IO (Either E.IOException String)
76getTemplateFromCabalDataDirectory :: String -> IO (Either E.IOException String)
76−getTemplateFromCabalDataDirectory format = E.try $ do
77+getTemplateFromCabalDataDirectory format = E.try $
77− templatePath <- getDataFileName $ "templates" </> format <.> "template"
78+ readDataFile $ "templates" </> format <.> "template"
78− readFile templatePath
79
79
80-- | Renders a template
80-- | Renders a template
81renderTemplate :: [(String,String)] -- ^ Assoc. list of values for variables
81renderTemplate :: [(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 (
37 writeS5String,
37 writeS5String,
38 insertS5Structure
38 insertS5Structure
39 ) where
39 ) where
40−import Text.Pandoc.Shared ( WriterOptions )
40+import Text.Pandoc.Shared ( WriterOptions, readDataFile )
41import Text.Pandoc.Writers.HTML ( writeHtml, writeHtmlString )
41import Text.Pandoc.Writers.HTML ( writeHtml, writeHtmlString )
42import Text.Pandoc.Definition
42import Text.Pandoc.Definition
43import Text.XHtml.Strict
43import Text.XHtml.Strict
@@ -45,10 +45,6 @@ import System.FilePath ( (</>) )
45import Data.List ( intercalate )
45import Data.List ( intercalate )
46import Prelude hiding (readFile)
46import Prelude hiding (readFile)
47import System.IO.UTF8 (readFile)
47import System.IO.UTF8 (readFile)
48−import Paths_pandoc (getDataFileName)
49−
50−readDataFile :: FilePath -> IO String
51−readDataFile fname = getDataFileName fname >>= readFile
52
48
53s5HeaderIncludes :: IO String
49s5HeaderIncludes :: IO String
54s5HeaderIncludes = do
50s5HeaderIncludes = do