From ba32c2ec42182bcd7bdb995f90cd1405353fa400 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Fri, 1 Aug 2008 06:35:42 +0000 Subject: Simplified build process using template haskell. + Text/Pandoc/ASCIIMathML.hs, Text/Pandoc/DefaultHeaders.hs, and Text/Pandoc/Writers/S5.hs are no longer built in Setup.hs from templates in the templates/ directory. + Instead, they use template haskell to read data at compile time from the relevant files in data/. + Setup.hs is back to the default simple configuration. + Removed old templates and Extra-Tmp-Files field from pandoc.cabal. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1357 788f1e2b-df1e-0410-8736-df70ead52e1b --- Text/Pandoc/ASCIIMathML.hs | 11 ++++ Text/Pandoc/DefaultHeaders.hs | 59 ++++++++++++++++++ Text/Pandoc/Writers/S5.hs | 141 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 211 insertions(+) create mode 100644 Text/Pandoc/ASCIIMathML.hs create mode 100644 Text/Pandoc/DefaultHeaders.hs create mode 100644 Text/Pandoc/Writers/S5.hs (limited to 'Text') 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/Text/Pandoc/DefaultHeaders.hs b/Text/Pandoc/DefaultHeaders.hs new file mode 100644 index 000000000..b918002d8 --- /dev/null +++ b/Text/Pandoc/DefaultHeaders.hs @@ -0,0 +1,59 @@ +{-# LANGUAGE TemplateHaskell #-} +{- +Copyright (C) 2006-7 John MacFarlane + +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.DefaultHeaders + Copyright : Copyright (C) 2006-7 John MacFarlane + License : GNU GPL, version 2 or above + + Maintainer : John MacFarlane + Stability : alpha + Portability : portable + +Default headers for Pandoc writers. +-} +module Text.Pandoc.DefaultHeaders ( + defaultLaTeXHeader, + defaultConTeXtHeader, + defaultDocbookHeader, + defaultOpenDocumentHeader, + defaultS5Header, + defaultRTFHeader + ) where +import Text.Pandoc.Writers.S5 +import System.FilePath ( () ) +import Text.Pandoc.Shared ( contentsOf ) + +defaultLaTeXHeader :: String +defaultLaTeXHeader = $(contentsOf $ "data" "headers" "LaTeX.header") + +defaultConTeXtHeader :: String +defaultConTeXtHeader = $(contentsOf $ "data" "headers" "ConTeXt.header") + +defaultDocbookHeader :: String +defaultDocbookHeader = $(contentsOf $ "data" "headers" "Docbook.header") + +defaultOpenDocumentHeader :: String +defaultOpenDocumentHeader = $(contentsOf $ "data" "headers" "OpenDocument.header") + +defaultS5Header :: String +defaultS5Header = s5Meta ++ s5CSS ++ s5Javascript + +defaultRTFHeader :: String +defaultRTFHeader = $(contentsOf $ "data" "headers" "RTF.header") diff --git a/Text/Pandoc/Writers/S5.hs b/Text/Pandoc/Writers/S5.hs new file mode 100644 index 000000000..e4cc9b08b --- /dev/null +++ b/Text/Pandoc/Writers/S5.hs @@ -0,0 +1,141 @@ +{-# LANGUAGE TemplateHaskell #-} +{- +Copyright (C) 2006-7 John MacFarlane + +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.Writers.S5 + Copyright : Copyright (C) 2006-7 John MacFarlane + License : GNU GPL, version 2 or above + + Maintainer : John MacFarlane + Stability : alpha + Portability : portable + +Definitions for creation of S5 powerpoint-like HTML. +(See .) +-} +module Text.Pandoc.Writers.S5 ( + -- * Strings + s5Meta, + s5Javascript, + s5CSS, + s5Links, + -- * Functions + writeS5, + writeS5String, + insertS5Structure + ) where +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" + +s5CoreCSS :: String +s5CoreCSS = $(contentsOf $ "data" "ui" "default" "s5-core.css") + +s5FramingCSS :: String +s5FramingCSS = $(contentsOf $ "data" "ui" "default" "framing.css") + +s5PrettyCSS :: String +s5PrettyCSS = $(contentsOf $ "data" "ui" "default" "pretty.css") + +s5OperaCSS :: String +s5OperaCSS = $(contentsOf $ "data" "ui" "default" "opera.css") + +s5OutlineCSS :: String +s5OutlineCSS = $(contentsOf $ "data" "ui" "default" "outline.css") + +s5PrintCSS :: String +s5PrintCSS = $(contentsOf $ "data" "ui" "default" "print.css") + +s5CSS :: String +s5CSS = "\n\n\n\n" + +s5Links :: String +s5Links = "\n\n\n\n\n\n\n" + +-- | Converts Pandoc document to an S5 HTML presentation (Html structure). +writeS5 :: WriterOptions -> Pandoc -> Html +writeS5 options = (writeHtml options) . insertS5Structure + +-- | Converts Pandoc document to an S5 HTML presentation (string). +writeS5String :: WriterOptions -> Pandoc -> String +writeS5String options = (writeHtmlString options) . insertS5Structure + +-- | Inserts HTML needed for an S5 presentation (e.g. around slides). +layoutDiv :: [Inline] -- ^ Title of document (for header or footer) + -> String -- ^ Date of document (for header or footer) + -> [Block] -- ^ List of block elements returned +layoutDiv title' date = [(RawHtml "
\n
\n
\n
\n
\n"), (Header 1 [Str date]), (Header 2 title'), (RawHtml "
\n
\n")] + +presentationStart :: Block +presentationStart = RawHtml "
\n\n" + +presentationEnd :: Block +presentationEnd = RawHtml "
\n" + +slideStart :: Block +slideStart = RawHtml "
\n" + +slideEnd :: Block +slideEnd = RawHtml "
\n" + +-- | Returns 'True' if block is a Header 1. +isH1 :: Block -> Bool +isH1 (Header 1 _) = True +isH1 _ = False + +-- | Insert HTML around sections to make individual slides. +insertSlides :: Bool -> [Block] -> [Block] +insertSlides beginning blocks = + let (beforeHead, rest) = break isH1 blocks in + if (null rest) then + if beginning then + beforeHead + else + beforeHead ++ [slideEnd] + else + if beginning then + beforeHead ++ + slideStart:(head rest):(insertSlides False (tail rest)) + else + beforeHead ++ + slideEnd:slideStart:(head rest):(insertSlides False (tail rest)) + +-- | Insert blocks into 'Pandoc' for slide structure. +insertS5Structure :: Pandoc -> Pandoc +insertS5Structure (Pandoc meta' []) = Pandoc meta' [] +insertS5Structure (Pandoc (Meta title' authors date) blocks) = + let slides = insertSlides True blocks + firstSlide = if not (null title') + then [slideStart, (Header 1 title'), + (Header 3 [Str (joinWithSep ", " authors)]), + (Header 4 [Str date]), slideEnd] + else [] + newBlocks = (layoutDiv title' date) ++ presentationStart:firstSlide ++ + slides ++ [presentationEnd] + in Pandoc (Meta title' authors date) newBlocks -- cgit v1.2.3