git.iko.soy/typeable/pandoc
on master help sign in
Removed TH dependency from S5 module, removed DefaultTemplates.

S5 module now exports s5HeaderIncludes, which pandoc.hs includes if writer is s5 and standalone. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1691 788f1e2b-df1e-0410-8736-df70ead52e1b

commitae44c7297f5ce12a3f1acd8c44efe11870805c0c authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 31 Dec 2009, 01:11 (17 years ago) parent9551e36
4 files changed+63−142
pandoc.cabal+21−27 src/Text/Pandoc/DefaultTemplates.hs−69 src/Text/Pandoc/Writers/S5.hs+30−45 src/pandoc.hs+12−1
pandoc.cabal+21−27
@@ -34,29 +34,21 @@ Description: Pandoc is a Haskell library for converting from one markup
3434 which convert this native representation into a target
3535 format. Thus, adding an input or output format requires
3636 only adding a reader or writer.
37−Data-Files: templates/html.template, templates/docbook.template,
37+Data-Files:
38+ -- templates
39+ templates/html.template, templates/docbook.template,
3840 templates/opendocument.template, templates/latex.template,
3941 templates/context.template, templates/texinfo.template,
4042 templates/man.template, templates/markdown.template,
4143 templates/rst.template, templates/s5.template,
42− templates/mediawiki.template, templates/rtf.template
43− -- documentation
44− README, INSTALL, COPYRIGHT, BUGS, changelog,
45− -- wrappers
46− markdown2pdf, html2markdown, hsmarkdown
47−Extra-Source-Files:
48− -- sources for man pages
49− man/man1/pandoc.1.md, man/man1/markdown2pdf.1.md,
50− man/man1/html2markdown.1.md, man/man1/hsmarkdown.1.md,
51− -- Makefile
52− Makefile,
53− -- data for DefaultTemplates.hs
54− data/templates/ConTeXt.template,
55− data/templates/Docbook.template,
56− data/templates/LaTeX.template,
57− data/templates/OpenDocument.template,
58− data/templates/RTF.template,
59− data/templates/S5.template,
44+ templates/mediawiki.template, templates/rtf.template,
45+ -- data for ODT writer
46+ data/odt-styles/meta.xml,
47+ data/odt-styles/settings.xml,
48+ data/odt-styles/META-INF/manifest.xml,
49+ data/odt-styles/Thumbnails/thumbnail.png,
50+ data/odt-styles/styles.xml,
51+ data/odt-styles/mimetype,
6052 -- data for LaTeXMathML writer
6153 data/LaTeXMathML.js.comment,
6254 data/LaTeXMathML.js.packed,
@@ -69,13 +61,16 @@ Extra-Source-Files:
6961 data/ui/default/opera.css,
7062 data/ui/default/outline.css,
7163 data/ui/default/print.css,
72− -- data for ODT writer
73− data/odt-styles/meta.xml,
74− data/odt-styles/settings.xml,
75− data/odt-styles/META-INF/manifest.xml,
76− data/odt-styles/Thumbnails/thumbnail.png,
77− data/odt-styles/styles.xml,
78− data/odt-styles/mimetype,
64+ -- documentation
65+ README, INSTALL, COPYRIGHT, BUGS, changelog,
66+ -- wrappers
67+ markdown2pdf, html2markdown, hsmarkdown
68+Extra-Source-Files:
69+ -- sources for man pages
70+ man/man1/pandoc.1.md, man/man1/markdown2pdf.1.md,
71+ man/man1/html2markdown.1.md, man/man1/hsmarkdown.1.md,
72+ -- Makefile
73+ Makefile,
7974 -- tests
8075 tests/bodybg.gif,
8176 tests/writer.latex,
@@ -177,7 +172,6 @@ Library
177172 Text.Pandoc.Shared,
178173 Text.Pandoc.ODT,
179174 Text.Pandoc.LaTeXMathML,
180− Text.Pandoc.DefaultTemplates,
181175 Text.Pandoc.Highlighting,
182176 Text.Pandoc.Readers.HTML,
183177 Text.Pandoc.Readers.LaTeX,
src/Text/Pandoc/DefaultTemplates.hsdeleted−69
@@ -1,69 +0,0 @@
1−{-# LANGUAGE CPP, TemplateHaskell #-}
2−{-
3−Copyright (C) 2006-7 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.DefaultTemplates
22− Copyright : Copyright (C) 2006-7 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−Default templates for Pandoc writers.
30−-}
31−module Text.Pandoc.DefaultTemplates ( defaultLaTeXTemplate,
32− defaultConTeXtTemplate,
33− defaultDocbookTemplate,
34− defaultOpenDocumentTemplate,
35− defaultS5Template,
36− defaultRTFTemplate
37− ) where
38−import Text.Pandoc.Writers.S5
39−import Text.Pandoc.Shared
40−import System.FilePath ( (</>) )
41−import Text.Pandoc.TH ( contentsOf )
42−
43−defaultLaTeXTemplate :: String
44−#ifndef __HADDOCK__
45−defaultLaTeXTemplate = $(contentsOf $ "data" </> "templates" </> "LaTeX.template")
46−#endif
47−
48−defaultConTeXtTemplate :: String
49−#ifndef __HADDOCK__
50−defaultConTeXtTemplate = $(contentsOf $ "data" </> "templates" </> "ConTeXt.template")
51−#endif
52−
53−defaultDocbookTemplate :: String
54−#ifndef __HADDOCK__
55−defaultDocbookTemplate = $(contentsOf $ "data" </> "templates" </> "Docbook.template")
56−#endif
57−
58−defaultOpenDocumentTemplate :: String
59−#ifndef __HADDOCK__
60−defaultOpenDocumentTemplate = $(contentsOf $ "data" </> "templates" </> "OpenDocument.template")
61−#endif
62−
63−defaultS5Template :: String
64−defaultS5Template = substitute "$" "$$" $ s5Meta ++ s5CSS ++ s5Javascript
65−
66−defaultRTFTemplate :: String
67−#ifndef __HADDOCK__
68−defaultRTFTemplate = $(contentsOf $ "data" </> "templates" </> "RTF.template")
69−#endif
src/Text/Pandoc/Writers/S5.hs+30−45
@@ -1,4 +1,3 @@
1−{-# LANGUAGE CPP, TemplateHaskell #-}
21{-
32Copyright (C) 2006-7 John MacFarlane <jgm@berkeley.edu>
43
@@ -30,10 +29,8 @@ Definitions for creation of S5 powerpoint-like HTML.
3029(See <http://meyerweb.com/eric/tools/s5/>.)
3130-}
3231module Text.Pandoc.Writers.S5 (
33− -- * Strings
34− s5Meta,
35− s5Javascript,
36− s5CSS,
32+ -- * Header includes
33+ s5HeaderIncludes,
3734 s5Links,
3835 -- * Functions
3936 writeS5,
@@ -41,55 +38,43 @@ module Text.Pandoc.Writers.S5 (
4138 insertS5Structure
4239 ) where
4340import Text.Pandoc.Shared ( WriterOptions )
44−import Text.Pandoc.TH ( contentsOf )
4541import Text.Pandoc.Writers.HTML ( writeHtml, writeHtmlString )
4642import Text.Pandoc.Definition
4743import Text.XHtml.Strict
4844import System.FilePath ( (</>) )
4945import Data.List ( intercalate )
46+import Prelude hiding (readFile)
47+import System.IO.UTF8 (readFile)
48+import Paths_pandoc (getDataFileName)
49+
50+readDataFile :: FilePath -> IO String
51+readDataFile fname = getDataFileName fname >>= readFile
52+
53+s5HeaderIncludes :: IO String
54+s5HeaderIncludes = do
55+ c <- s5CSS
56+ j <- s5Javascript
57+ return $ s5Meta ++ c ++ j
5058
5159s5Meta :: String
5260s5Meta = "<!-- configuration parameters -->\n<meta name=\"defaultView\" content=\"slideshow\" />\n<meta name=\"controlVis\" content=\"hidden\" />\n"
5361
54−s5Javascript :: String
55−#ifndef __HADDOCK__
56−s5Javascript = "<script type=\"text/javascript\">\n" ++
57− $(contentsOf $ "data" </> "ui" </> "default" </> "slides.js.comment") ++
58− $(contentsOf $ "data" </> "ui" </> "default" </> "slides.js.packed") ++ "</script>\n"
59−#endif
60−
61−s5CoreCSS :: String
62−#ifndef __HADDOCK__
63−s5CoreCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "s5-core.css")
64−#endif
65−
66−s5FramingCSS :: String
67−#ifndef __HADDOCK__
68−s5FramingCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "framing.css")
69−#endif
70−
71−s5PrettyCSS :: String
72−#ifndef __HADDOCK__
73−s5PrettyCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "pretty.css")
74−#endif
75−
76−s5OperaCSS :: String
77−#ifndef __HADDOCK__
78−s5OperaCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "opera.css")
79−#endif
80−
81−s5OutlineCSS :: String
82−#ifndef __HADDOCK__
83−s5OutlineCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "outline.css")
84−#endif
85−
86−s5PrintCSS :: String
87−#ifndef __HADDOCK__
88−s5PrintCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "print.css")
89−#endif
90−
91−s5CSS :: String
92−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"
62+s5Javascript :: IO String
63+s5Javascript = do
64+ jsCom <- readDataFile $ "data" </> "ui" </> "default" </> "slides.js.comment"
65+ jsPacked <- readDataFile $ "data" </> "ui" </> "default" </> "slides.js.packed"
66+ return $ "<script type=\"text/javascript\">\n" ++ jsCom ++ jsPacked ++
67+ "</script>\n"
68+
69+s5CSS :: IO String
70+s5CSS = do
71+ s5CoreCSS <- readDataFile $ "data" </> "ui" </> "default" </> "s5-core.css"
72+ s5FramingCSS <- readDataFile $ "data" </> "ui" </> "default" </> "framing.css"
73+ s5PrettyCSS <- readDataFile $ "data" </> "ui" </> "default" </> "pretty.css"
74+ s5OperaCSS <- readDataFile $ "data" </> "ui" </> "default" </> "opera.css"
75+ s5OutlineCSS <- readDataFile $ "data" </> "ui" </> "default" </> "outline.css"
76+ s5PrintCSS <- readDataFile $ "data" </> "ui" </> "default" </> "print.css"
77+ return $ "<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"
9378
9479s5Links :: String
9580s5Links = "<!-- style sheet links -->\n<link rel=\"stylesheet\" href=\"ui/default/slides.css\" type=\"text/css\" media=\"projection\" id=\"slideProj\" />\n<link rel=\"stylesheet\" href=\"ui/default/outline.css\" type=\"text/css\" media=\"screen\" id=\"outlineStyle\" />\n<link rel=\"stylesheet\" href=\"ui/default/print.css\" type=\"text/css\" media=\"print\" id=\"slidePrint\" />\n<link rel=\"stylesheet\" href=\"ui/default/opera.css\" type=\"text/css\" media=\"projection\" id=\"operaFix\" />\n<!-- S5 JS -->\n<script src=\"ui/default/slides.js\" type=\"text/javascript\"></script>\n"
src/pandoc.hs+12−1
@@ -32,6 +32,7 @@ writers.
3232module Main where
3333import Text.Pandoc
3434import Text.Pandoc.ODT
35+import Text.Pandoc.Writers.S5 (s5HeaderIncludes)
3536import Text.Pandoc.Templates (getDefaultTemplate)
3637import Text.Pandoc.Shared ( HTMLMathMethod (..), tabFilter, ObfuscationMethod (..) )
3738#ifdef _HIGHLIGHTING
@@ -631,6 +632,16 @@ main = do
631632 refs <- if null biblioFile then return [] else readBiblioFile biblioFile biblioFormat
632633#endif
633634
635+ variables' <- if writerName' == "s5" && standalone'
636+ then do
637+ inc <- s5HeaderIncludes
638+ return $ case lookup "header-includes" variables of
639+ Nothing -> ("header-includes", inc) : variables
640+ Just a -> ("header-includes", a ++ inc) :
641+ filter ((/= "header-includes") . fst)
642+ variables
643+ else return variables
644+
634645 let startParserState =
635646 defaultParserState { stateParseRaw = parseRaw,
636647 stateTabStop = tabStop,
@@ -650,7 +661,7 @@ main = do
650661 writerTemplate = if null template
651662 then defaultTemplate
652663 else template,
653− writerVariables = variables,
664+ writerVariables = variables',
654665 writerTabStop = tabStop,
655666 writerTableOfContents = toc &&
656667 writerName' /= "s5",