diff --git a/Makefile b/Makefile index e3b474f2c..f450d36d5 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/Setup.hs b/Setup.hs index 2162f9860..200a2e51d 100644 --- a/Setup.hs +++ b/Setup.hs @@ -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 .) +module Text.Pandoc.ASCIIMathML ( asciiMathMLScript ) where +import Text.Pandoc.Shared ( contentsOf ) + +-- | String containing ASCIIMathML javascript. +asciiMathMLScript :: String +asciiMathMLScript = "\n" diff --git a/templates/DefaultHeaders.hs b/Text/Pandoc/DefaultHeaders.hs similarity index 76% rename from templates/DefaultHeaders.hs rename to 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 @@ -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 similarity index 86% rename from templates/S5.hs rename to 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 @@ -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 = "\n\n\n" s5Javascript :: String -s5Javascript = "\n" +s5Javascript = "\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 = "\n\n\n\n" diff --git a/templates/ASCIIMathML.js b/data/ASCIIMathML.js similarity index 100% rename from templates/ASCIIMathML.js rename to data/ASCIIMathML.js diff --git a/templates/ASCIIMathML.js.comment b/data/ASCIIMathML.js.comment similarity index 100% rename from templates/ASCIIMathML.js.comment rename to data/ASCIIMathML.js.comment diff --git a/templates/ASCIIMathML.js.packed b/data/ASCIIMathML.js.packed similarity index 100% rename from templates/ASCIIMathML.js.packed rename to data/ASCIIMathML.js.packed diff --git a/templates/headers/ConTeXt.header b/data/headers/ConTeXt.header similarity index 100% rename from templates/headers/ConTeXt.header rename to data/headers/ConTeXt.header diff --git a/templates/headers/Docbook.header b/data/headers/Docbook.header similarity index 100% rename from templates/headers/Docbook.header rename to data/headers/Docbook.header diff --git a/templates/headers/LaTeX.header b/data/headers/LaTeX.header similarity index 100% rename from templates/headers/LaTeX.header rename to data/headers/LaTeX.header diff --git a/templates/headers/OpenDocument.header b/data/headers/OpenDocument.header similarity index 100% rename from templates/headers/OpenDocument.header rename to data/headers/OpenDocument.header diff --git a/templates/headers/RTF.header b/data/headers/RTF.header similarity index 100% rename from templates/headers/RTF.header rename to data/headers/RTF.header diff --git a/templates/headers/S5.header b/data/headers/S5.header similarity index 100% rename from templates/headers/S5.header rename to data/headers/S5.header diff --git a/templates/ui/default/blank.gif b/data/ui/default/blank.gif similarity index 100% rename from templates/ui/default/blank.gif rename to data/ui/default/blank.gif diff --git a/templates/ui/default/bodybg.gif b/data/ui/default/bodybg.gif similarity index 100% rename from templates/ui/default/bodybg.gif rename to data/ui/default/bodybg.gif diff --git a/templates/ui/default/framing.css b/data/ui/default/framing.css similarity index 100% rename from templates/ui/default/framing.css rename to data/ui/default/framing.css diff --git a/templates/ui/default/iepngfix.htc b/data/ui/default/iepngfix.htc similarity index 100% rename from templates/ui/default/iepngfix.htc rename to data/ui/default/iepngfix.htc diff --git a/templates/ui/default/opera.css b/data/ui/default/opera.css similarity index 100% rename from templates/ui/default/opera.css rename to data/ui/default/opera.css diff --git a/templates/ui/default/outline.css b/data/ui/default/outline.css similarity index 100% rename from templates/ui/default/outline.css rename to data/ui/default/outline.css diff --git a/templates/ui/default/pretty.css b/data/ui/default/pretty.css similarity index 100% rename from templates/ui/default/pretty.css rename to data/ui/default/pretty.css diff --git a/templates/ui/default/print.css b/data/ui/default/print.css similarity index 100% rename from templates/ui/default/print.css rename to data/ui/default/print.css diff --git a/templates/ui/default/s5-core.css b/data/ui/default/s5-core.css similarity index 100% rename from templates/ui/default/s5-core.css rename to data/ui/default/s5-core.css diff --git a/templates/ui/default/slides.css b/data/ui/default/slides.css similarity index 100% rename from templates/ui/default/slides.css rename to data/ui/default/slides.css diff --git a/templates/ui/default/slides.js b/data/ui/default/slides.js similarity index 100% rename from templates/ui/default/slides.js rename to data/ui/default/slides.js diff --git a/templates/ui/default/slides.js.comment b/data/ui/default/slides.js.comment similarity index 100% rename from templates/ui/default/slides.js.comment rename to data/ui/default/slides.js.comment diff --git a/templates/ui/default/slides.js.packed b/data/ui/default/slides.js.packed similarity index 100% rename from templates/ui/default/slides.js.packed rename to 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 .) -module Text.Pandoc.ASCIIMathML ( asciiMathMLScript ) where - --- | String containing ASCIIMathML javascript. -asciiMathMLScript :: String -asciiMathMLScript = "\n"