git.iko.soy/typeable/pandoc
on master help sign in
Removed TH dependency from S5 module, removed DefaultTemplates.
ae44c72fiddlosopher
pandoc.cabal+21−27
@@ -34,29 +34,21 @@ Description: Pandoc is a Haskell library for converting from one markup
34 which convert this native representation into a target
34 which convert this native representation into a target
35 format. Thus, adding an input or output format requires
35 format. Thus, adding an input or output format requires
36 only adding a reader or writer.
36 only adding a reader or writer.
37+Data-Files:
38+ -- templates
37−Data-Files: templates/html.template, templates/docbook.template,
39+ templates/html.template, templates/docbook.template,
38 templates/opendocument.template, templates/latex.template,
40 templates/opendocument.template, templates/latex.template,
39 templates/context.template, templates/texinfo.template,
41 templates/context.template, templates/texinfo.template,
40 templates/man.template, templates/markdown.template,
42 templates/man.template, templates/markdown.template,
41 templates/rst.template, templates/s5.template,
43 templates/rst.template, templates/s5.template,
42− templates/mediawiki.template, templates/rtf.template
44+ templates/mediawiki.template, templates/rtf.template,
43− -- documentation
45+ -- data for ODT writer
44− README, INSTALL, COPYRIGHT, BUGS, changelog,
46+ data/odt-styles/meta.xml,
45− -- wrappers
47+ data/odt-styles/settings.xml,
46− markdown2pdf, html2markdown, hsmarkdown
48+ data/odt-styles/META-INF/manifest.xml,
47−Extra-Source-Files:
49+ data/odt-styles/Thumbnails/thumbnail.png,
48− -- sources for man pages
50+ data/odt-styles/styles.xml,
49− man/man1/pandoc.1.md, man/man1/markdown2pdf.1.md,
51+ data/odt-styles/mimetype,
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,
60 -- data for LaTeXMathML writer
52 -- data for LaTeXMathML writer
61 data/LaTeXMathML.js.comment,
53 data/LaTeXMathML.js.comment,
62 data/LaTeXMathML.js.packed,
54 data/LaTeXMathML.js.packed,
@@ -69,13 +61,16 @@ Extra-Source-Files:
69 data/ui/default/opera.css,
61 data/ui/default/opera.css,
70 data/ui/default/outline.css,
62 data/ui/default/outline.css,
71 data/ui/default/print.css,
63 data/ui/default/print.css,
72− -- data for ODT writer
64+ -- documentation
73− data/odt-styles/meta.xml,
65+ README, INSTALL, COPYRIGHT, BUGS, changelog,
74− data/odt-styles/settings.xml,
66+ -- wrappers
75− data/odt-styles/META-INF/manifest.xml,
67+ markdown2pdf, html2markdown, hsmarkdown
76− data/odt-styles/Thumbnails/thumbnail.png,
68+Extra-Source-Files:
77− data/odt-styles/styles.xml,
69+ -- sources for man pages
78− data/odt-styles/mimetype,
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,
79 -- tests
74 -- tests
80 tests/bodybg.gif,
75 tests/bodybg.gif,
81 tests/writer.latex,
76 tests/writer.latex,
@@ -177,7 +172,6 @@ Library
177 Text.Pandoc.Shared,
172 Text.Pandoc.Shared,
178 Text.Pandoc.ODT,
173 Text.Pandoc.ODT,
179 Text.Pandoc.LaTeXMathML,
174 Text.Pandoc.LaTeXMathML,
180− Text.Pandoc.DefaultTemplates,
181 Text.Pandoc.Highlighting,
175 Text.Pandoc.Highlighting,
182 Text.Pandoc.Readers.HTML,
176 Text.Pandoc.Readers.HTML,
183 Text.Pandoc.Readers.LaTeX,
177 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 #-}
2{-
1{-
3Copyright (C) 2006-7 John MacFarlane <jgm@berkeley.edu>
2Copyright (C) 2006-7 John MacFarlane <jgm@berkeley.edu>
4
3
@@ -30,10 +29,8 @@ Definitions for creation of S5 powerpoint-like HTML.
30(See <http://meyerweb.com/eric/tools/s5/>.)
29(See <http://meyerweb.com/eric/tools/s5/>.)
31-}
30-}
32module Text.Pandoc.Writers.S5 (
31module Text.Pandoc.Writers.S5 (
33− -- * Strings
32+ -- * Header includes
34− s5Meta,
33+ s5HeaderIncludes,
35− s5Javascript,
36− s5CSS,
37 s5Links,
34 s5Links,
38 -- * Functions
35 -- * Functions
39 writeS5,
36 writeS5,
@@ -41,55 +38,43 @@ module Text.Pandoc.Writers.S5 (
41 insertS5Structure
38 insertS5Structure
42 ) where
39 ) where
43import Text.Pandoc.Shared ( WriterOptions )
40import Text.Pandoc.Shared ( WriterOptions )
44−import Text.Pandoc.TH ( contentsOf )
45import Text.Pandoc.Writers.HTML ( writeHtml, writeHtmlString )
41import Text.Pandoc.Writers.HTML ( writeHtml, writeHtmlString )
46import Text.Pandoc.Definition
42import Text.Pandoc.Definition
47import Text.XHtml.Strict
43import Text.XHtml.Strict
48import System.FilePath ( (</>) )
44import System.FilePath ( (</>) )
49import Data.List ( intercalate )
45import 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
50
58
51s5Meta :: String
59s5Meta :: String
52s5Meta = "<!-- configuration parameters -->\n<meta name=\"defaultView\" content=\"slideshow\" />\n<meta name=\"controlVis\" content=\"hidden\" />\n"
60s5Meta = "<!-- configuration parameters -->\n<meta name=\"defaultView\" content=\"slideshow\" />\n<meta name=\"controlVis\" content=\"hidden\" />\n"
53
61
54−s5Javascript :: String
62+s5Javascript :: IO String
55−#ifndef __HADDOCK__
56−s5Javascript = "<script type=\"text/javascript\">\n" ++
63+s5Javascript = do
57− $(contentsOf $ "data" </> "ui" </> "default" </> "slides.js.comment") ++
64+ jsCom <- readDataFile $ "data" </> "ui" </> "default" </> "slides.js.comment"
58− $(contentsOf $ "data" </> "ui" </> "default" </> "slides.js.packed") ++ "</script>\n"
65+ jsPacked <- readDataFile $ "data" </> "ui" </> "default" </> "slides.js.packed"
59−#endif
66+ return $ "<script type=\"text/javascript\">\n" ++ jsCom ++ jsPacked ++
60−
67+ "</script>\n"
68+
61−s5CoreCSS :: String
69+s5CSS :: IO String
62−#ifndef __HADDOCK__
70+s5CSS = do
63−s5CoreCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "s5-core.css")
71+ s5CoreCSS <- readDataFile $ "data" </> "ui" </> "default" </> "s5-core.css"
64−#endif
65−
66−s5FramingCSS :: String
67−#ifndef __HADDOCK__
68−s5FramingCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "framing.css")
72+ s5FramingCSS <- readDataFile $ "data" </> "ui" </> "default" </> "framing.css"
69−#endif
70−
71−s5PrettyCSS :: String
72−#ifndef __HADDOCK__
73−s5PrettyCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "pretty.css")
73+ s5PrettyCSS <- readDataFile $ "data" </> "ui" </> "default" </> "pretty.css"
74−#endif
75−
76−s5OperaCSS :: String
77−#ifndef __HADDOCK__
78−s5OperaCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "opera.css")
74+ s5OperaCSS <- readDataFile $ "data" </> "ui" </> "default" </> "opera.css"
79−#endif
80−
81−s5OutlineCSS :: String
82−#ifndef __HADDOCK__
83−s5OutlineCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "outline.css")
75+ s5OutlineCSS <- readDataFile $ "data" </> "ui" </> "default" </> "outline.css"
84−#endif
85−
86−s5PrintCSS :: String
87−#ifndef __HADDOCK__
88−s5PrintCSS = $(contentsOf $ "data" </> "ui" </> "default" </> "print.css")
76+ s5PrintCSS <- readDataFile $ "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"
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"
93
78
94s5Links :: String
79s5Links :: String
95s5Links = "<!-- 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"
80s5Links = "<!-- 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.
32module Main where
32module Main where
33import Text.Pandoc
33import Text.Pandoc
34import Text.Pandoc.ODT
34import Text.Pandoc.ODT
35+import Text.Pandoc.Writers.S5 (s5HeaderIncludes)
35import Text.Pandoc.Templates (getDefaultTemplate)
36import Text.Pandoc.Templates (getDefaultTemplate)
36import Text.Pandoc.Shared ( HTMLMathMethod (..), tabFilter, ObfuscationMethod (..) )
37import Text.Pandoc.Shared ( HTMLMathMethod (..), tabFilter, ObfuscationMethod (..) )
37#ifdef _HIGHLIGHTING
38#ifdef _HIGHLIGHTING
@@ -631,6 +632,16 @@ main = do
631 refs <- if null biblioFile then return [] else readBiblioFile biblioFile biblioFormat
632 refs <- if null biblioFile then return [] else readBiblioFile biblioFile biblioFormat
632#endif
633#endif
633
634
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+
634 let startParserState =
645 let startParserState =
635 defaultParserState { stateParseRaw = parseRaw,
646 defaultParserState { stateParseRaw = parseRaw,
636 stateTabStop = tabStop,
647 stateTabStop = tabStop,
@@ -650,7 +661,7 @@ main = do
650 writerTemplate = if null template
661 writerTemplate = if null template
651 then defaultTemplate
662 then defaultTemplate
652 else template,
663 else template,
653− writerVariables = variables,
664+ writerVariables = variables',
654 writerTabStop = tabStop,
665 writerTabStop = tabStop,
655 writerTableOfContents = toc &&
666 writerTableOfContents = toc &&
656 writerName' /= "s5",
667 writerName' /= "s5",