diff options
-rw-r--r-- | Makefile | 12 | ||||
-rw-r--r-- | Setup.hs | 69 | ||||
-rw-r--r-- | Text/Pandoc/ASCIIMathML.hs | 11 | ||||
-rw-r--r-- | Text/Pandoc/DefaultHeaders.hs (renamed from templates/DefaultHeaders.hs) | 13 | ||||
-rw-r--r-- | Text/Pandoc/Writers/S5.hs (renamed from templates/S5.hs) | 20 | ||||
-rw-r--r-- | data/ASCIIMathML.js (renamed from templates/ASCIIMathML.js) | 0 | ||||
-rw-r--r-- | data/ASCIIMathML.js.comment (renamed from templates/ASCIIMathML.js.comment) | 0 | ||||
-rw-r--r-- | data/ASCIIMathML.js.packed (renamed from templates/ASCIIMathML.js.packed) | 0 | ||||
-rw-r--r-- | data/headers/ConTeXt.header (renamed from templates/headers/ConTeXt.header) | 0 | ||||
-rw-r--r-- | data/headers/Docbook.header (renamed from templates/headers/Docbook.header) | 0 | ||||
-rw-r--r-- | data/headers/LaTeX.header (renamed from templates/headers/LaTeX.header) | 0 | ||||
-rw-r--r-- | data/headers/OpenDocument.header (renamed from templates/headers/OpenDocument.header) | 0 | ||||
-rw-r--r-- | data/headers/RTF.header (renamed from templates/headers/RTF.header) | 0 | ||||
-rw-r--r-- | data/headers/S5.header (renamed from templates/headers/S5.header) | 0 | ||||
-rw-r--r-- | data/ui/default/blank.gif (renamed from templates/ui/default/blank.gif) | bin | 49 -> 49 bytes | |||
-rw-r--r-- | data/ui/default/bodybg.gif (renamed from templates/ui/default/bodybg.gif) | bin | 10119 -> 10119 bytes | |||
-rw-r--r-- | data/ui/default/framing.css (renamed from templates/ui/default/framing.css) | 0 | ||||
-rw-r--r-- | data/ui/default/iepngfix.htc (renamed from templates/ui/default/iepngfix.htc) | 0 | ||||
-rw-r--r-- | data/ui/default/opera.css (renamed from templates/ui/default/opera.css) | 0 | ||||
-rw-r--r-- | data/ui/default/outline.css (renamed from templates/ui/default/outline.css) | 0 | ||||
-rw-r--r-- | data/ui/default/pretty.css (renamed from templates/ui/default/pretty.css) | 0 | ||||
-rw-r--r-- | data/ui/default/print.css (renamed from templates/ui/default/print.css) | 0 | ||||
-rw-r--r-- | data/ui/default/s5-core.css (renamed from templates/ui/default/s5-core.css) | 0 | ||||
-rw-r--r-- | data/ui/default/slides.css (renamed from templates/ui/default/slides.css) | 0 | ||||
-rw-r--r-- | data/ui/default/slides.js (renamed from templates/ui/default/slides.js) | 0 | ||||
-rw-r--r-- | data/ui/default/slides.js.comment (renamed from templates/ui/default/slides.js.comment) | 0 | ||||
-rw-r--r-- | data/ui/default/slides.js.packed (renamed from templates/ui/default/slides.js.packed) | 0 | ||||
-rw-r--r-- | pandoc.cabal | 41 | ||||
-rw-r--r-- | templates/ASCIIMathML.hs | 7 |
29 files changed, 52 insertions, 121 deletions
@@ -189,14 +189,6 @@ uninstall-doc: -for f in $(man_all); do rm -f $(MANPATH)/$$f; done rmdir $(PKGDOCPATH) 2>/dev/null ||: -# Data file installation. -.PHONY: install-data uninstall-data -install-data: $(ODTREF) - $(INSTALL) -d $(PKGDATAPATH) && $(INSTALL_DATA) $(ODTREF) $(PKGDATAPATH)/ -uninstall-data: - -rm -f $(PKGDATAPATH)/$(notdir $(ODTREF)) - rmdir $(PKGDATAPATH) 2>/dev/null ||: - # Program only installation. .PHONY: install-exec uninstall-exec install-exec: build-exec @@ -213,8 +205,8 @@ uninstall-exec: # Program + user documents installation. .PHONY: install-program uninstall-program -install-program: install-exec install-data install-doc -uninstall-program: uninstall-exec uninstall-doc uninstall-data +install-program: install-exec install-doc +uninstall-program: uninstall-exec uninstall-doc .PHONY: install-all uninstall-all # Full installation through Cabal: main + wrappers + user docs + lib + lib docs @@ -1,70 +1,3 @@ import Distribution.Simple -import Distribution.Simple.Setup -import Distribution.PackageDescription -import Distribution.Simple.LocalBuildInfo -import System.FilePath (combine, joinPath, takeFileName, takeExtension) -import System.Directory (getDirectoryContents, removeFile, copyFile) -import System.IO (readFile, writeFile) -import Control.Monad (foldM) -import Data.List (isPrefixOf) - -main = defaultMainWithHooks $ simpleUserHooks { postConf = myPostConf } - -pandocPath = combine "Text" "Pandoc" - --- Builds Text/Pandoc/ASCIIMathML.hs, Text/Pandoc/Writers/S5.hs, and --- Text/Pandoc/Writers/DefaultHeaders.hs from templates and data. -myPostConf :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO () -myPostConf _ configFlags pkgDescription buildInfo = do - putStrLn "Generating source files from templates..." - fillAsciiMathMLTemplate - fillS5WriterTemplate - fillDefaultHeadersTemplate - --- Fill templateFile with data in dataFiles and write to outputFile. -fillTemplate :: [FilePath] -> FilePath -> FilePath -> IO () -fillTemplate dataFiles templateFile outputFile = do - template <- readFile (combine "templates" templateFile) - filled <- foldM processFile template $ map (combine "templates") dataFiles - writeTemplate (combine pandocPath outputFile) filled - -fillAsciiMathMLTemplate :: IO () -fillAsciiMathMLTemplate = - fillTemplate ["ASCIIMathML.js.comment", "ASCIIMathML.js.packed"] "ASCIIMathML.hs" "ASCIIMathML.hs" - -fillS5WriterTemplate :: IO () -fillS5WriterTemplate = - let s5Path = joinPath ["ui", "default"] - files = map (combine s5Path) ["slides.js.comment", "slides.js.packed", "s5-core.css", - "framing.css", "pretty.css", "opera.css", "outline.css", "print.css"] - in fillTemplate files "S5.hs" (combine "Writers" "S5.hs") - -fillDefaultHeadersTemplate :: IO () -fillDefaultHeadersTemplate = do - files <- getDirectoryContents (combine "templates" "headers") >>= - return . map (combine "headers") . filter (\x -> takeExtension x == ".header") - fillTemplate files "DefaultHeaders.hs" "DefaultHeaders.hs" - --- Write the filled template file and print an explanatory message. -writeTemplate :: FilePath -> String -> IO () -writeTemplate outfile contents = do - putStrLn $ " " ++ outfile - let warning = "-- This file is generated from a template in the templates subdirectory.\n" ++ - "-- Modify that file, not this one.\n" - writeFile outfile (warning ++ contents) - --- Read contents of fpath and insert in template replacing @fpath@. -processFile :: String -> FilePath -> IO String -processFile template fpath = do - contents <- readFile fpath >>= return . show - return $ substitute ("@" ++ takeFileName fpath ++ "@") contents template - --- Replace each occurrence of one sublist in a list with another. -substitute :: (Eq a) => [a] -> [a] -> [a] -> [a] -substitute _ _ [] = [] -substitute [] _ lst = lst -substitute target replacement lst = - if target `isPrefixOf` lst - then replacement ++ (substitute target replacement $ drop (length target) lst) - else (head lst):(substitute target replacement $ tail lst) +main = defaultMain diff --git a/Text/Pandoc/ASCIIMathML.hs b/Text/Pandoc/ASCIIMathML.hs new file mode 100644 index 000000000..2f634b0b0 --- /dev/null +++ b/Text/Pandoc/ASCIIMathML.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE TemplateHaskell #-} +-- | Definitions for use of ASCIIMathML in HTML. +-- (See <http://www1.chapman.edu/~jipsen/mathml/asciimath.html>.) +module Text.Pandoc.ASCIIMathML ( asciiMathMLScript ) where +import Text.Pandoc.Shared ( contentsOf ) + +-- | String containing ASCIIMathML javascript. +asciiMathMLScript :: String +asciiMathMLScript = "<script type=\"text/javascript\">\n" ++ + $(contentsOf $ "data/ASCIIMathML.js.comment") ++ + $(contentsOf $ "data/ASCIIMathML.js.packed") ++ "</script>\n" diff --git a/templates/DefaultHeaders.hs b/Text/Pandoc/DefaultHeaders.hs index 01e5f0dd4..b918002d8 100644 --- a/templates/DefaultHeaders.hs +++ b/Text/Pandoc/DefaultHeaders.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE TemplateHaskell #-} {- Copyright (C) 2006-7 John MacFarlane <jgm@berkeley.edu> @@ -36,21 +37,23 @@ module Text.Pandoc.DefaultHeaders ( defaultRTFHeader ) where import Text.Pandoc.Writers.S5 +import System.FilePath ( (</>) ) +import Text.Pandoc.Shared ( contentsOf ) defaultLaTeXHeader :: String -defaultLaTeXHeader = @LaTeX.header@ +defaultLaTeXHeader = $(contentsOf $ "data" </> "headers" </> "LaTeX.header") defaultConTeXtHeader :: String -defaultConTeXtHeader = @ConTeXt.header@ +defaultConTeXtHeader = $(contentsOf $ "data" </> "headers" </> "ConTeXt.header") defaultDocbookHeader :: String -defaultDocbookHeader = @Docbook.header@ +defaultDocbookHeader = $(contentsOf $ "data" </> "headers" </> "Docbook.header") defaultOpenDocumentHeader :: String -defaultOpenDocumentHeader = @OpenDocument.header@ +defaultOpenDocumentHeader = $(contentsOf $ "data" </> "headers" </> "OpenDocument.header") defaultS5Header :: String defaultS5Header = s5Meta ++ s5CSS ++ s5Javascript defaultRTFHeader :: String -defaultRTFHeader = @RTF.header@ +defaultRTFHeader = $(contentsOf $ "data" </> "headers" </> "RTF.header") diff --git a/templates/S5.hs b/Text/Pandoc/Writers/S5.hs index e2c02f40d..e4cc9b08b 100644 --- a/templates/S5.hs +++ b/Text/Pandoc/Writers/S5.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE TemplateHaskell #-} {- Copyright (C) 2006-7 John MacFarlane <jgm@berkeley.edu> @@ -39,34 +40,37 @@ module Text.Pandoc.Writers.S5 ( writeS5String, insertS5Structure ) where -import Text.Pandoc.Shared ( joinWithSep, WriterOptions ) +import Text.Pandoc.Shared ( joinWithSep, WriterOptions, contentsOf ) import Text.Pandoc.Writers.HTML ( writeHtml, writeHtmlString ) import Text.Pandoc.Definition import Text.XHtml.Strict +import System.FilePath ( (</>) ) s5Meta :: String s5Meta = "<!-- configuration parameters -->\n<meta name=\"defaultView\" content=\"slideshow\" />\n<meta name=\"controlVis\" content=\"hidden\" />\n" s5Javascript :: String -s5Javascript = "<script type=\"text/javascript\">\n" ++ @slides.js.comment@ ++ @slides.js.packed@ ++ "</script>\n" +s5Javascript = "<script type=\"text/javascript\">\n" ++ + $(contentsOf $ "data" </> "ui" </> "default" </> "slides.js.comment") ++ + $(contentsOf $ "data" </> "ui" </> "default" </> "slides.js.packed") ++ "</script>\n" s5CoreCSS :: String -s5CoreCSS = @s5-core.css@ +s5CoreCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "s5-core.css") s5FramingCSS :: String -s5FramingCSS = @framing.css@ +s5FramingCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "framing.css") s5PrettyCSS :: String -s5PrettyCSS = @pretty.css@ +s5PrettyCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "pretty.css") s5OperaCSS :: String -s5OperaCSS = @opera.css@ +s5OperaCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "opera.css") s5OutlineCSS :: String -s5OutlineCSS = @outline.css@ +s5OutlineCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "outline.css") s5PrintCSS :: String -s5PrintCSS = @print.css@ +s5PrintCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "print.css") s5CSS :: String s5CSS = "<style type=\"text/css\" media=\"projection\" id=\"slideProj\">\n" ++ s5CoreCSS ++ "\n" ++ s5FramingCSS ++ "\n" ++ s5PrettyCSS ++ "\n</style>\n<style type=\"text/css\" media=\"projection\" id=\"operaFix\">\n" ++ s5OperaCSS ++ "\n</style>\n<style type=\"text/css\" media=\"screen\" id=\"outlineStyle\">\n" ++ s5OutlineCSS ++ "\n</style>\n<style type=\"text/css\" media=\"print\" id=\"slidePrint\">\n" ++ s5PrintCSS ++ "\n</style>\n" diff --git a/templates/ASCIIMathML.js b/data/ASCIIMathML.js index ddb2604e2..ddb2604e2 100644 --- a/templates/ASCIIMathML.js +++ b/data/ASCIIMathML.js diff --git a/templates/ASCIIMathML.js.comment b/data/ASCIIMathML.js.comment index 8721031e1..8721031e1 100644 --- a/templates/ASCIIMathML.js.comment +++ b/data/ASCIIMathML.js.comment diff --git a/templates/ASCIIMathML.js.packed b/data/ASCIIMathML.js.packed index eabb35af7..eabb35af7 100644 --- a/templates/ASCIIMathML.js.packed +++ b/data/ASCIIMathML.js.packed diff --git a/templates/headers/ConTeXt.header b/data/headers/ConTeXt.header index d19b41c45..d19b41c45 100644 --- a/templates/headers/ConTeXt.header +++ b/data/headers/ConTeXt.header diff --git a/templates/headers/Docbook.header b/data/headers/Docbook.header index 7b26b2c73..7b26b2c73 100644 --- a/templates/headers/Docbook.header +++ b/data/headers/Docbook.header diff --git a/templates/headers/LaTeX.header b/data/headers/LaTeX.header index a6729cf2d..a6729cf2d 100644 --- a/templates/headers/LaTeX.header +++ b/data/headers/LaTeX.header diff --git a/templates/headers/OpenDocument.header b/data/headers/OpenDocument.header index 17ed4fd9f..17ed4fd9f 100644 --- a/templates/headers/OpenDocument.header +++ b/data/headers/OpenDocument.header diff --git a/templates/headers/RTF.header b/data/headers/RTF.header index b4368694b..b4368694b 100644 --- a/templates/headers/RTF.header +++ b/data/headers/RTF.header diff --git a/templates/headers/S5.header b/data/headers/S5.header index ebb24ebe2..ebb24ebe2 100644 --- a/templates/headers/S5.header +++ b/data/headers/S5.header diff --git a/templates/ui/default/blank.gif b/data/ui/default/blank.gif Binary files differindex 75b945d25..75b945d25 100644 --- a/templates/ui/default/blank.gif +++ b/data/ui/default/blank.gif diff --git a/templates/ui/default/bodybg.gif b/data/ui/default/bodybg.gif Binary files differindex 5f448a16f..5f448a16f 100644 --- a/templates/ui/default/bodybg.gif +++ b/data/ui/default/bodybg.gif diff --git a/templates/ui/default/framing.css b/data/ui/default/framing.css index 14d8509e9..14d8509e9 100644 --- a/templates/ui/default/framing.css +++ b/data/ui/default/framing.css diff --git a/templates/ui/default/iepngfix.htc b/data/ui/default/iepngfix.htc index bba2db756..bba2db756 100644 --- a/templates/ui/default/iepngfix.htc +++ b/data/ui/default/iepngfix.htc diff --git a/templates/ui/default/opera.css b/data/ui/default/opera.css index 9e9d2a3c5..9e9d2a3c5 100644 --- a/templates/ui/default/opera.css +++ b/data/ui/default/opera.css diff --git a/templates/ui/default/outline.css b/data/ui/default/outline.css index 62db519ed..62db519ed 100644 --- a/templates/ui/default/outline.css +++ b/data/ui/default/outline.css diff --git a/templates/ui/default/pretty.css b/data/ui/default/pretty.css index a87b24375..a87b24375 100644 --- a/templates/ui/default/pretty.css +++ b/data/ui/default/pretty.css diff --git a/templates/ui/default/print.css b/data/ui/default/print.css index 4a3554ddd..4a3554ddd 100644 --- a/templates/ui/default/print.css +++ b/data/ui/default/print.css diff --git a/templates/ui/default/s5-core.css b/data/ui/default/s5-core.css index 86444e041..86444e041 100644 --- a/templates/ui/default/s5-core.css +++ b/data/ui/default/s5-core.css diff --git a/templates/ui/default/slides.css b/data/ui/default/slides.css index 0786d7dbd..0786d7dbd 100644 --- a/templates/ui/default/slides.css +++ b/data/ui/default/slides.css diff --git a/templates/ui/default/slides.js b/data/ui/default/slides.js index 38fe8531c..38fe8531c 100644 --- a/templates/ui/default/slides.js +++ b/data/ui/default/slides.js diff --git a/templates/ui/default/slides.js.comment b/data/ui/default/slides.js.comment index 489b276a2..489b276a2 100644 --- a/templates/ui/default/slides.js.comment +++ b/data/ui/default/slides.js.comment diff --git a/templates/ui/default/slides.js.packed b/data/ui/default/slides.js.packed index 47b95e53f..47b95e53f 100644 --- a/templates/ui/default/slides.js.packed +++ b/data/ui/default/slides.js.packed diff --git a/pandoc.cabal b/pandoc.cabal index 3c2ab5061..400bcfd5f 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -1,7 +1,7 @@ Name: pandoc Version: 0.47 Cabal-Version: >= 1.2 -Build-Type: Custom +Build-Type: Simple License: GPL License-File: COPYING Copyright: (c) 2006-2008 John MacFarlane @@ -35,29 +35,23 @@ Description: Pandoc is a Haskell library for converting from one markup format. Thus, adding an input or output format requires only adding a reader or writer. Extra-Source-Files: README, INSTALL, COPYRIGHT, COPYING, - templates/ASCIIMathML.js.comment, - templates/ASCIIMathML.js.packed, - templates/ASCIIMathML.hs, - templates/S5.hs, - templates/DefaultHeaders.hs, - templates/headers/ConTeXt.header, - templates/headers/Docbook.header, - templates/headers/LaTeX.header, - templates/headers/OpenDocument.header, - templates/headers/RTF.header, - templates/headers/S5.header, - templates/ui/default/slides.js.comment, - templates/ui/default/slides.js.packed, - templates/ui/default/s5-core.css, - templates/ui/default/framing.css, - templates/ui/default/pretty.css, - templates/ui/default/opera.css, - templates/ui/default/outline.css, - templates/ui/default/print.css, + data/ASCIIMathML.js.comment, + data/ASCIIMathML.js.packed, + data/headers/ConTeXt.header, + data/headers/Docbook.header, + data/headers/LaTeX.header, + data/headers/OpenDocument.header, + data/headers/RTF.header, + data/headers/S5.header, + data/ui/default/slides.js.comment, + data/ui/default/slides.js.packed, + data/ui/default/s5-core.css, + data/ui/default/framing.css, + data/ui/default/pretty.css, + data/ui/default/opera.css, + data/ui/default/outline.css, + data/ui/default/print.css, odt-styles/reference.odt -Extra-Tmp-Files: Text/Pandoc/ASCIIMathML.hs, - Text/Pandoc/DefaultHeaders.hs, - Text/Pandoc/Writers/S5.hs Flag splitBase Description: Choose the new, smaller, split-up base package. Default: True @@ -112,6 +106,7 @@ Library Text.XML.Light.Types, Text.XML.Light.Output, Text.XML.Light.Input, + Text.XML.Light.Proc, Text.XML.Light.Cursor Ghc-Options: -O2 -Wall -threaded Ghc-Prof-Options: -auto-all diff --git a/templates/ASCIIMathML.hs b/templates/ASCIIMathML.hs deleted file mode 100644 index b3454d385..000000000 --- a/templates/ASCIIMathML.hs +++ /dev/null @@ -1,7 +0,0 @@ --- | Definitions for use of ASCIIMathML in HTML. --- (See <http://www1.chapman.edu/~jipsen/mathml/asciimath.html>.) -module Text.Pandoc.ASCIIMathML ( asciiMathMLScript ) where - --- | String containing ASCIIMathML javascript. -asciiMathMLScript :: String -asciiMathMLScript = "<script type=\"text/javascript\">\n" ++ @ASCIIMathML.js.comment@ ++ @ASCIIMathML.js.packed@ ++ "</script>\n" |