git.iko.soy/typeable/pandoc
on master help sign in
Use template haskell to avoid the need for templates:

+ Added library Text.Pandoc.Include, with a template haskell function $(includeStrFrom fname) to include a file as a string constant at compile time. + This removes the need for the 'templates' directory or Makefile target. These have been removed. + The base source directory has been changed from src to . + A new 'data' directory has been added, containing the ASCIIMathML.js script, writer headers, and S5 files. + The src/wrappers directory has been moved to 'wrappers'. + The Text.Pandoc.ASCIIMathML library is no longer needed, since Text.Pandoc.Writers.HTML can use includeStrFrom to include the ASCIIMathML.js code directly. It has been removed. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1063 788f1e2b-df1e-0410-8736-df70ead52e1b

commit4a841bfc5464907adea4cdd655485565565b40ae authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 3 Nov 2007, 22:14 (19 years ago) parent3116d30
51 files changed+137−200
INSTALL+1−4 src/Main.hs → Main.hs Makefile+2−8 src/Text/Pandoc.hs → Text/Pandoc.hs src/Text/Pandoc/Blocks.hs → Text/Pandoc/Blocks.hs src/Text/Pandoc/CharacterReferences.hs → Text/Pandoc/CharacterReferences.hs src/Text/Pandoc/Definition.hs → Text/Pandoc/Definition.hs Text/Pandoc/Include.hs+60 src/Text/Pandoc/Readers/HTML.hs → Text/Pandoc/Readers/HTML.hs src/Text/Pandoc/Readers/LaTeX.hs → Text/Pandoc/Readers/LaTeX.hs src/Text/Pandoc/Readers/Markdown.hs → Text/Pandoc/Readers/Markdown.hs src/Text/Pandoc/Readers/RST.hs → Text/Pandoc/Readers/RST.hs src/Text/Pandoc/Shared.hs → Text/Pandoc/Shared.hs src/Text/Pandoc/UTF8.hs → Text/Pandoc/UTF8.hs src/Text/Pandoc/Writers/ConTeXt.hs → Text/Pandoc/Writers/ConTeXt.hs src/templates/DefaultHeaders.hs → Text/Pandoc/Writers/DefaultHeaders.hs+6−4 src/Text/Pandoc/Writers/Docbook.hs → Text/Pandoc/Writers/Docbook.hs src/Text/Pandoc/Writers/HTML.hs → Text/Pandoc/Writers/HTML.hs+6−2 src/Text/Pandoc/Writers/LaTeX.hs → Text/Pandoc/Writers/LaTeX.hs src/Text/Pandoc/Writers/Man.hs → Text/Pandoc/Writers/Man.hs src/Text/Pandoc/Writers/Markdown.hs → Text/Pandoc/Writers/Markdown.hs src/Text/Pandoc/Writers/RST.hs → Text/Pandoc/Writers/RST.hs src/Text/Pandoc/Writers/RTF.hs → Text/Pandoc/Writers/RTF.hs src/templates/S5.hs → Text/Pandoc/Writers/S5.hs+10−7 src/ASCIIMathML.js → data/ASCIIMathML.js src/headers/ConTeXtHeader → data/headers/ConTeXtHeader src/headers/DocbookHeader → data/headers/DocbookHeader src/headers/LaTeXHeader → data/headers/LaTeXHeader src/headers/RTFHeader → data/headers/RTFHeader src/headers/S5Header → data/headers/S5Header src/ui/default/blank.gif → data/ui/default/blank.gif src/ui/default/bodybg.gif → data/ui/default/bodybg.gif src/ui/default/framing.css → data/ui/default/framing.css src/ui/default/iepngfix.htc → data/ui/default/iepngfix.htc src/ui/default/opera.css → data/ui/default/opera.css src/ui/default/outline.css → data/ui/default/outline.css src/ui/default/pretty.css → data/ui/default/pretty.css src/ui/default/print.css → data/ui/default/print.css src/ui/default/s5-core.css → data/ui/default/s5-core.css src/ui/default/slides.css → data/ui/default/slides.css src/ui/default/slides.js → data/ui/default/slides.js pandoc.cabal+6−6 src/templates/ASCIIMathML.hs−7 src/templates/Makefile−20 src/templates/fillTemplates.pl−131 tests/s5.fancy.html+46−11 src/wrappers/common.sh → wrappers/common.sh src/wrappers/hsmarkdown.in → wrappers/hsmarkdown.in src/wrappers/html2markdown.in → wrappers/html2markdown.in src/wrappers/markdown2pdf.in → wrappers/markdown2pdf.in src/wrappers/tempdir.sh → wrappers/tempdir.sh
INSTALL+1−4
@@ -107,15 +107,12 @@ but are documented here for packagers and developers:
107107
108108* `configure`: Performs the needed preprocessing to create a proper
109109 Cabal package for Pandoc:
110− - Builds `ASCIIMathML.hs`, `DefaultHeaders.hs`, and `S5.hs`
111− from templates in `src/templates` and data in `src/ASCIIMathML.js`,
112− `src/ui`, and `src/headers`.
113110 - Stores values of relevant environment variables in `vars` for
114111 persistence.
115112 - Runs Cabal's "configure" command.
116113* `build-exec`: Builds `pandoc` executable (using Cabal's "build"
117114 command) and creates the wrappers `html2markdown` and `markdown2pdf`
118− from templates in `src/wrappers`.
115+ from templates in `wrappers`.
119116* `build-doc`: Builds program documentation (e.g. `README.html`).
120117* `build-lib-doc`: Builds Haddock documentation for Pandoc libraries.
121118* `install-doc`, `uninstall-doc`: Installs/uninstalls user documentation
src/Main.hs → Main.hsrenamed

The content is the same.

Makefile+2−8
@@ -4,7 +4,7 @@
44# Constant names and commands in source tree
55#-------------------------------------------------------------------------------
66CABAL := pandoc.cabal
7−SRCDIR := src
7+SRCDIR := .
88MANDIR := man
99TESTDIR := tests
1010BUILDDIR := dist
@@ -91,10 +91,6 @@ all: build-program
9191%.1: %.1.md $(MAIN)
9292 ./$(MAIN) -s -S -w man $< >$@ || rm -f $@
9393
94−.PHONY: templates
95−templates: $(SRCDIR)/templates
96− $(MAKE) -C $(SRCDIR)/templates
97−
9894define generate-shell-script
9995echo >&2 "Generating $@..."; \
10096awk ' \
@@ -118,7 +114,7 @@ $(WRAPPERS): %: $(SRCDIR)/wrappers/%.in $(SRCDIR)/wrappers/*.sh
118114
119115.PHONY: configure
120116cleanup_files+=Setup.hi Setup.o $(BUILDCMD) $(BUILDVARS)
121−configure: $(BUILDCONF) templates
117+configure: $(BUILDCONF)
122118$(BUILDCONF): $(CABAL)
123119 ghc -package Cabal Setup.hs -o $(BUILDCMD)
124120 $(BUILDCMD) configure --prefix=$(PREFIX)
@@ -283,7 +279,6 @@ cleanup_files+=$(tarball)
283279tarball: $(tarball)
284280$(tarball):
285281 svn export . $(PKGID)
286− $(MAKE) -C $(PKGID) templates
287282 $(MAKE) -C $(PKGID) wrappers
288283 tar cvzf $(tarball) $(PKGID)
289284 -rm -rf $(PKGID)
@@ -343,6 +338,5 @@ distclean: clean
343338 fi
344339
345340clean:
346− make -C $(SRCDIR)/templates clean
347341 -if [ -f $(BUILDCONF) ]; then $(BUILDCMD) clean; fi
348342 -rm -rf $(cleanup_files)
src/Text/Pandoc.hs → Text/Pandoc.hsrenamed

The content is the same.

src/Text/Pandoc/Blocks.hs → Text/Pandoc/Blocks.hsrenamed

The content is the same.

src/Text/Pandoc/CharacterReferences.hs → Text/Pandoc/CharacterReferences.hsrenamed

The content is the same.

src/Text/Pandoc/Definition.hs → Text/Pandoc/Definition.hsrenamed

The content is the same.

Text/Pandoc/Include.hsnew file+60
@@ -0,0 +1,60 @@
1+{-
2+Copyright (C) 2007 John MacFarlane <jgm@berkeley.edu>
3+
4+This program is free software; you can redistribute it and/or modify
5+it under the terms of the GNU General Public License as published by
6+the Free Software Foundation; either version 2 of the License, or
7+(at your option) any later version.
8+
9+This program is distributed in the hope that it will be useful,
10+but WITHOUT ANY WARRANTY; without even the implied warranty of
11+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+GNU General Public License for more details.
13+
14+You should have received a copy of the GNU General Public License
15+along with this program; if not, write to the Free Software
16+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17+-}
18+
19+{- |
20+ Module : Text.Pandoc.Include
21+ Copyright : Copyright (C) 2006-7 John MacFarlane
22+ License : GNU GPL, version 2 or above
23+
24+ Maintainer : John MacFarlane <jgm@berkeley.edu>
25+ Stability : alpha
26+ Portability : portable
27+
28+Template Haskell functions for including contents of files at compile time.
29+Usage: myConstant = $(includeStrFrom "myfile")
30+Note that "myfile" need be present only at compile time.
31+-}
32+module Text.Pandoc.Include ( includeStrFrom
33+ , s5Path
34+ , asciiMathMLPath
35+ , headerPath
36+ ) where
37+
38+import Language.Haskell.TH
39+import Control.Monad (liftM)
40+import System.FilePath
41+
42+-- path of data files
43+dataPath = "data"
44+
45+-- | Include contents of file as a string.
46+includeStrFrom :: FilePath -> ExpQ
47+includeStrFrom fpath = (runIO $ readFile fpath) >>= stringE
48+
49+-- | Path of an S5 file.
50+s5Path :: FilePath -> FilePath
51+s5Path p = joinPath [dataPath,"ui","default",p]
52+
53+-- | Path of ASCIIMathML.js.
54+asciiMathMLPath :: FilePath
55+asciiMathMLPath = joinPath [dataPath,"ASCIIMathML.js"]
56+
57+-- | Path of headers.
58+headerPath :: FilePath -> FilePath
59+headerPath p = joinPath [dataPath,"headers",p]
60+
src/Text/Pandoc/Readers/HTML.hs → Text/Pandoc/Readers/HTML.hsrenamed

The content is the same.

src/Text/Pandoc/Readers/LaTeX.hs → Text/Pandoc/Readers/LaTeX.hsrenamed

The content is the same.

src/Text/Pandoc/Readers/Markdown.hs → Text/Pandoc/Readers/Markdown.hsrenamed

The content is the same.

src/Text/Pandoc/Readers/RST.hs → Text/Pandoc/Readers/RST.hsrenamed

The content is the same.

src/Text/Pandoc/Shared.hs → Text/Pandoc/Shared.hsrenamed

The content is the same.

src/Text/Pandoc/UTF8.hs → Text/Pandoc/UTF8.hsrenamed

The content is the same.

src/Text/Pandoc/Writers/ConTeXt.hs → Text/Pandoc/Writers/ConTeXt.hsrenamed

The content is the same.

src/templates/DefaultHeaders.hs → Text/Pandoc/Writers/DefaultHeaders.hsrenamed+6−4
@@ -35,18 +35,20 @@ module Text.Pandoc.Writers.DefaultHeaders (
3535 defaultRTFHeader
3636 ) where
3737import Text.Pandoc.Writers.S5
38+import Text.Pandoc.Include ( includeStrFrom, headerPath )
3839
3940defaultLaTeXHeader :: String
40−defaultLaTeXHeader = "@LaTeXHeader@"
41+defaultLaTeXHeader = $(includeStrFrom $ headerPath "LaTeXHeader")
4142
4243defaultConTeXtHeader :: String
43−defaultConTeXtHeader = "@ConTeXtHeader@"
44+defaultConTeXtHeader = $(includeStrFrom $ headerPath "ConTeXtHeader")
4445
4546defaultDocbookHeader :: String
46−defaultDocbookHeader = "@DocbookHeader@"
47+defaultDocbookHeader = $(includeStrFrom $ headerPath "DocbookHeader")
4748
4849defaultS5Header :: String
4950defaultS5Header = s5Meta ++ s5CSS ++ s5Javascript
5051
5152defaultRTFHeader :: String
52−defaultRTFHeader = "@RTFHeader@"
53+defaultRTFHeader = $(includeStrFrom $ headerPath "RTFHeader")
54+
src/Text/Pandoc/Writers/Docbook.hs → Text/Pandoc/Writers/Docbook.hsrenamed

The content is the same.

src/Text/Pandoc/Writers/HTML.hs → Text/Pandoc/Writers/HTML.hsrenamed+6−2
@@ -29,7 +29,6 @@ Conversion of 'Pandoc' documents to HTML.
2929-}
3030module Text.Pandoc.Writers.HTML ( writeHtml , writeHtmlString ) where
3131import Text.Pandoc.Definition
32−import Text.Pandoc.ASCIIMathML
3332import Text.Pandoc.CharacterReferences ( decodeCharacterReferences )
3433import Text.Pandoc.Shared
3534import Text.Regex ( mkRegex, matchRegex )
@@ -39,6 +38,7 @@ import Data.List ( isPrefixOf, intersperse )
3938import qualified Data.Set as S
4039import Control.Monad.State
4140import Text.XHtml.Transitional
41+import Text.Pandoc.Include ( includeStrFrom, asciiMathMLPath )
4242
4343data WriterState = WriterState
4444 { stNotes :: [Html] -- ^ List of notes
@@ -47,6 +47,8 @@ data WriterState = WriterState
4747 , stCSS :: S.Set String -- ^ CSS to include in header
4848 } deriving Show
4949
50+asciiMathMLScript = $(includeStrFrom asciiMathMLPath)
51+
5052defaultWriterState :: WriterState
5153defaultWriterState = WriterState {stNotes= [], stIds = [],
5254 stMath = False, stCSS = S.empty}
@@ -104,7 +106,9 @@ writeHtml opts (Pandoc (Meta tit authors date) blocks) =
104106 Just path -> script ! [src path,
105107 thetype "text/javascript"] $
106108 noHtml
107− Nothing -> primHtml asciiMathMLScript
109+ Nothing -> script !
110+ [thetype "text/javascript"] $
111+ primHtml asciiMathMLScript
108112 else noHtml
109113 head = header $ metadata +++ math +++ css +++
110114 primHtml (writerHeader opts)
src/Text/Pandoc/Writers/LaTeX.hs → Text/Pandoc/Writers/LaTeX.hsrenamed

The content is the same.

src/Text/Pandoc/Writers/Man.hs → Text/Pandoc/Writers/Man.hsrenamed

The content is the same.

src/Text/Pandoc/Writers/Markdown.hs → Text/Pandoc/Writers/Markdown.hsrenamed

The content is the same.

src/Text/Pandoc/Writers/RST.hs → Text/Pandoc/Writers/RST.hsrenamed

The content is the same.

src/Text/Pandoc/Writers/RTF.hs → Text/Pandoc/Writers/RTF.hsrenamed

The content is the same.

src/templates/S5.hs → Text/Pandoc/Writers/S5.hsrenamed+10−7
@@ -43,30 +43,33 @@ import Text.Pandoc.Shared ( joinWithSep, WriterOptions )
4343import Text.Pandoc.Writers.HTML ( writeHtml, writeHtmlString )
4444import Text.Pandoc.Definition
4545import Text.XHtml.Strict
46+import Text.Pandoc.Include ( includeStrFrom, s5Path )
4647
4748s5Meta :: String
4849s5Meta = "<!-- configuration parameters -->\n<meta name=\"defaultView\" content=\"slideshow\" />\n<meta name=\"controlVis\" content=\"hidden\" />\n"
4950
5051s5Javascript :: String
51−s5Javascript = "<script type=\"text/javascript\">\n@slides.js@</script>\n"
52+s5Javascript = "<script type=\"text/javascript\">\n" ++
53+ $(includeStrFrom $ s5Path "slides.js") ++
54+ "</script>\n"
5255
5356s5CoreCSS :: String
54−s5CoreCSS = "@s5-core.css@"
57+s5CoreCSS = $(includeStrFrom $ s5Path "s5-core.css")
5558
5659s5FramingCSS :: String
57−s5FramingCSS = "@framing.css@"
60+s5FramingCSS = $(includeStrFrom $ s5Path "framing.css")
5861
5962s5PrettyCSS :: String
60−s5PrettyCSS = "@pretty.css@"
63+s5PrettyCSS = $(includeStrFrom $ s5Path "pretty.css")
6164
6265s5OperaCSS :: String
63−s5OperaCSS = "@opera.css@"
66+s5OperaCSS = $(includeStrFrom $ s5Path "opera.css")
6467
6568s5OutlineCSS :: String
66−s5OutlineCSS = "@outline.css@"
69+s5OutlineCSS = $(includeStrFrom $ s5Path "outline.css")
6770
6871s5PrintCSS :: String
69−s5PrintCSS = "@print.css@"
72+s5PrintCSS = $(includeStrFrom $ s5Path "print.css")
7073
7174s5CSS :: String
7275s5CSS = "<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"
src/ASCIIMathML.js → data/ASCIIMathML.jsrenamed

The content is the same.

src/headers/ConTeXtHeader → data/headers/ConTeXtHeaderrenamed

The content is the same.

src/headers/DocbookHeader → data/headers/DocbookHeaderrenamed

The content is the same.

src/headers/LaTeXHeader → data/headers/LaTeXHeaderrenamed

The content is the same.

src/headers/RTFHeader → data/headers/RTFHeaderrenamed

The content is the same.

src/headers/S5Header → data/headers/S5Headerrenamed

The content is the same.

src/ui/default/blank.gif → data/ui/default/blank.gifrenamed

Binary file not shown.

src/ui/default/bodybg.gif → data/ui/default/bodybg.gifrenamed

Binary file not shown.

src/ui/default/framing.css → data/ui/default/framing.cssrenamed

The content is the same.

src/ui/default/iepngfix.htc → data/ui/default/iepngfix.htcrenamed

The content is the same.

src/ui/default/opera.css → data/ui/default/opera.cssrenamed

The content is the same.

src/ui/default/outline.css → data/ui/default/outline.cssrenamed

The content is the same.

src/ui/default/pretty.css → data/ui/default/pretty.cssrenamed

The content is the same.

src/ui/default/print.css → data/ui/default/print.cssrenamed

The content is the same.

src/ui/default/s5-core.css → data/ui/default/s5-core.cssrenamed

The content is the same.

src/ui/default/slides.css → data/ui/default/slides.cssrenamed

The content is the same.

src/ui/default/slides.js → data/ui/default/slides.jsrenamed

The content is the same.

pandoc.cabal+6−6
@@ -31,15 +31,14 @@ Description: Pandoc is a Haskell library for converting from one markup
3131 which convert this native representation into a target
3232 format. Thus, adding an input or output format requires
3333 only adding a reader or writer.
34−Build-Depends: base, parsec, xhtml, mtl, regex-compat, network
35−Hs-Source-Dirs: src
34+Build-Depends: base, parsec, xhtml, mtl, regex-compat, network, template-haskell, filepath
35+Hs-Source-Dirs: .
3636Exposed-Modules: Text.Pandoc,
3737 Text.Pandoc.Blocks,
3838 Text.Pandoc.Definition,
3939 Text.Pandoc.CharacterReferences,
4040 Text.Pandoc.Shared,
4141 Text.Pandoc.UTF8,
42− Text.Pandoc.ASCIIMathML,
4342 Text.Pandoc.Readers.HTML,
4443 Text.Pandoc.Readers.LaTeX,
4544 Text.Pandoc.Readers.Markdown,
@@ -54,9 +53,10 @@ Exposed-Modules: Text.Pandoc,
5453 Text.Pandoc.Writers.RST,
5554 Text.Pandoc.Writers.RTF,
5655 Text.Pandoc.Writers.S5
57−Ghc-Options: -O0
56+Other-Modules: Text.Pandoc.Include
57+Ghc-Options: -O0 -fth
5858
5959Executable: pandoc
60−Hs-Source-Dirs: src
60+Hs-Source-Dirs: .
6161Main-Is: Main.hs
62−Ghc-Options: -O0
62+Ghc-Options: -O0 -fth
src/templates/ASCIIMathML.hsdeleted−7
@@ -1,7 +0,0 @@
1−-- | Definitions for use of ASCIIMathML in HTML.
2−-- (See <http://www1.chapman.edu/~jipsen/mathml/asciimath.html>.)
3−module Text.Pandoc.ASCIIMathML ( asciiMathMLScript ) where
4−
5−-- | String containing ASCIIMathML javascript.
6−asciiMathMLScript :: String
7−asciiMathMLScript = "<script type=\"text/javascript\">\n@ASCIIMathML.js@</script>\n"
src/templates/Makefiledeleted−20
@@ -1,20 +0,0 @@
1−VPATH := ..
2−PROCESSOR := ./fillTemplates.pl
3−TARGETS := Text/Pandoc/ASCIIMathML.hs \
4− Text/Pandoc/Writers/S5.hs \
5− Text/Pandoc/Writers/DefaultHeaders.hs
6−
7−all: $(TARGETS)
8−
9−Text/Pandoc/ASCIIMathML.hs: ASCIIMathML.hs $(PROCESSOR) $(VPATH)/ASCIIMathML.js
10− perl $(PROCESSOR) $@ $(VPATH)
11−
12−Text/Pandoc/Writers/S5.hs: S5.hs $(PROCESSOR) $(VPATH)/ui/default/*
13− perl $(PROCESSOR) $@ $(VPATH)
14−
15−Text/Pandoc/Writers/DefaultHeaders.hs: DefaultHeaders.hs $(PROCESSOR) $(VPATH)/headers/*
16− perl $(PROCESSOR) $@ $(VPATH)
17−
18−.PHONY: clean
19−clean:
20− cd $(VPATH); rm -f $(TARGETS)
src/templates/fillTemplates.pldeleted−131
@@ -1,131 +0,0 @@
1−#!/usr/bin/env perl
2−# Fills templates with haskell-escaped strings slurped from input files.
3−# Takes two arguments, the first specifying the pathname of the target
4−# relative to the root directory, the second specifying the root directory
5−# (defaulting to ..). The template is assumed to have the same base name
6−# as the target and to reside in the templates subdirectory of the root
7−# directory.
8−
9−use strict;
10−use warnings;
11−
12−# Utility routines:
13−
14−sub slurp {
15− open FILE, $_[0] or die "couldn't open file '$_[0]': $!";
16− my $contents = do { local $/; <FILE>;};
17− close FILE;
18− return $contents;
19−}
20−
21−sub escape_for_haskell {
22− my ($contents) = @_;
23−
24− $contents =~ s/\\/\\\\/g;
25− $contents =~ s/\t/\\t/g;
26− $contents =~ s/"/\\"/g;
27− $contents =~ s/\n/\\n/g;
28− return $contents;
29−}
30−
31−# Template processors.
32−
33−my %processor = (
34− # --------------------------------------------------------------------------
35− 'Text/Pandoc/Writers/S5.hs' => {
36− # --------------------------------------------------------------------------
37− proc => sub {
38− my ($template) = @_;
39−
40− my (@files) = qw(slides.js s5-core.css framing.css pretty.css
41− opera.css outline.css print.css);
42−
43− foreach my $file (@files) {
44− my $replacement = escape_for_haskell(slurp "ui/default/$file");
45− my $escapedfile = $file;
46− $escapedfile =~ s/\./\\./g;
47− $template =~ s/\@$escapedfile\@/$replacement/;
48− }
49− return $template;
50− },
51− },
52− # --------------------------------------------------------------------------
53− 'Text/Pandoc/ASCIIMathML.hs' => {
54− # --------------------------------------------------------------------------
55− proc => sub {
56− my ($template) = @_;
57−
58− my $script = escape_for_haskell(slurp "ASCIIMathML.js");
59− my $acknowledgements =
60− " ASCIIMathML.js - copyright Peter Jipsen,".
61− " released under the GPL\\nSee ".
62− "http://www1.chapman.edu/~jipsen/mathml/asciimath.html/ ";
63− $script =~ s/\/\*.*?\*\//\/\*$acknowledgements\*\//g; # strip comments
64− $template =~ s/\@ASCIIMathML\.js@/$script/;
65−
66− return $template;
67− },
68− },
69− # --------------------------------------------------------------------------
70− 'Text/Pandoc/Writers/DefaultHeaders.hs' => {
71− # --------------------------------------------------------------------------
72− proc => sub {
73− my ($template) = @_;
74−
75− my (@headers) = split(/\s/,`ls headers`);
76− foreach my $header (@headers) {
77− my ($replacement) = escape_for_haskell(slurp "headers/$header");
78− $template =~ s/\@$header\@/$replacement/;
79− }
80−
81− return $template;
82− },
83− },
84− # --------------------------------------------------------------------------
85− # 'foo/bar/baz' => {
86− # --------------------------------------------------------------------------
87− # template => 'optional-template-filename-defaults-to-baz'
88− # proc => sub {
89− # my ($template) = @_;
90− # # Process.
91− # return $template;
92− # },
93− #},
94−);
95−
96−# Main.
97−
98−my $target = shift @ARGV;
99−if (!defined $target || !length $target) {
100− print STDERR "Available targets:\n\n" . join "\n", keys %processor;
101− die "\n\nYou must supply a target!\n";
102−}
103−
104−die "No processor exists for '$target'!\n" if ! exists $processor{$target};
105−
106−my $rootdir = shift @ARGV || '..';
107−chdir $rootdir or die "Couldn't chdir to '$rootdir': $!";
108−
109−my $template;
110−if (exists $processor{$target}->{template}) {
111− $template = $processor{$target}->{template};
112−}
113−else {
114− ($template = $target) =~ s!.*/+!!;
115−}
116−$template = "templates/$template";
117−die "No template exists for '$target'!\n" if ! -f "$template";
118−
119−open OUTFILE, ">$target" or die "couldn't open file '$target': $!";
120−print OUTFILE <<END;
121−----------------------------------------------------
122−-- Do not edit this file by hand. Edit
123−-- '$template'
124−-- and run $0 $target
125−----------------------------------------------------
126−
127−END
128−
129−print OUTFILE $processor{$target}->{proc}->(slurp($template));
130−print OUTFILE "\n";
131−close OUTFILE;
tests/s5.fancy.html+46−11
@@ -8,9 +8,38 @@
88 /><meta name="author" content="Sam Smith"
99 /><meta name="author" content="Jen Jones"
1010 /><meta name="date" content="July 15, 2006"
11− /><script type="text/javascript">
12−/* ASCIIMathML.js - copyright Peter Jipsen, released under the GPL
13−See http://www1.chapman.edu/~jipsen/mathml/asciimath.html/ */
11+ /><script type="text/javascript"
12+ >/*
13+ASCIIMathML.js
14+==============
15+This file contains JavaScript functions to convert ASCII math notation
16+to Presentation MathML. The conversion is done while the (X)HTML page
17+loads, and should work with Firefox/Mozilla/Netscape 7+ and Internet
18+Explorer 6+MathPlayer (http://www.dessci.com/en/products/mathplayer/).
19+Just add the next line to your (X)HTML page with this file in the same folder:
20+<script type="text/javascript" src="ASCIIMathML.js"></script>
21+This is a convenient and inexpensive solution for authoring MathML.
22+
23+Version 1.4.7 Dec 15, 2005, (c) Peter Jipsen http://www.chapman.edu/~jipsen
24+Latest version at http://www.chapman.edu/~jipsen/mathml/ASCIIMathML.js
25+For changes see http://www.chapman.edu/~jipsen/mathml/asciimathchanges.txt
26+If you use it on a webpage, please send the URL to jipsen@chapman.edu
27+
28+Modified July 2006 by John MacFarlane (added CODE to list of contexts
29+in which replacement does not occur, modified AMisMathMLAvailable
30+to better identify Safari browser, changed mathcolor to "").
31+
32+This program is free software; you can redistribute it and/or modify
33+it under the terms of the GNU General Public License as published by
34+the Free Software Foundation; either version 2 of the License, or (at
35+your option) any later version.
36+
37+This program is distributed in the hope that it will be useful,
38+but WITHOUT ANY WARRANTY; without even the implied warranty of
39+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
40+General Public License (at http://www.gnu.org/copyleft/gpl.html)
41+for more details.
42+*/
1443
1544var checkForMathML = true; // check if browser can display MathML
1645var notifyIfNoMathML = true; // display note if no MathML capability
@@ -59,8 +88,7 @@ function AMnoMathMLNote() {
5988}
6089
6190function AMisMathMLavailable() {
62− var regex = /KHTML/; /* ASCIIMathML.js - copyright Peter Jipsen, released under the GPL
63−See http://www1.chapman.edu/~jipsen/mathml/asciimath.html/ */
91+ var regex = /KHTML/; /* This line and the next two modified by JM for better Safari detection */
6492 if (navigator.appName.slice(0,8)=="Netscape")
6593 if (navigator.appVersion.slice(0,1)>="5" && !regex.test(navigator.userAgent)) return null;
6694 else return AMnoMathMLNote();
@@ -443,8 +471,16 @@ function AMremoveBrackets(node) {
443471 }
444472}
445473
446−/* ASCIIMathML.js - copyright Peter Jipsen, released under the GPL
447−See http://www1.chapman.edu/~jipsen/mathml/asciimath.html/ */
474+/*Parsing ASCII math expressions with the following grammar
475+v ::= [A-Za-z] | greek letters | numbers | other constant symbols
476+u ::= sqrt | text | bb | other unary symbols for font commands
477+b ::= frac | root | stackrel binary symbols
478+l ::= ( | [ | { | (: | {: left brackets
479+r ::= ) | ] | } | :) | :} right brackets
480+S ::= v | lEr | uS | bSS Simple expression
481+I ::= S_S | S^S | S_S^S | S Intermediate expression
482+E ::= IE | I/I Expression
483+Each terminal symbol is translated into a corresponding mathml node.*/
448484
449485var AMnestingDepth,AMpreviousSymbol,AMcurrentSymbol;
450486
@@ -783,8 +819,7 @@ function AMprocessNodeR(n, linebreaks) {
783819 if ((n.nodeType!=8 || linebreaks) &&
784820 n.parentNode.nodeName!="form" && n.parentNode.nodeName!="FORM" &&
785821 n.parentNode.nodeName!="textarea" && n.parentNode.nodeName!="TEXTAREA" &&
786− n.parentNode.nodeName!="code" && n.parentNode.nodeName!="CODE" && /* ASCIIMathML.js - copyright Peter Jipsen, released under the GPL
787−See http://www1.chapman.edu/~jipsen/mathml/asciimath.html/ */
822+ n.parentNode.nodeName!="code" && n.parentNode.nodeName!="CODE" && /* added by JM */
788823 n.parentNode.nodeName!="pre" && n.parentNode.nodeName!="PRE") {
789824 str = n.nodeValue;
790825 if (!(str == null)) {
@@ -919,8 +954,8 @@ else
919954 window.onload = generic;
920955 }
921956}
922−</script>
923−<!-- configuration parameters -->
957+</script
958+ ><!-- configuration parameters -->
924959<meta name="defaultView" content="slideshow" />
925960<meta name="controlVis" content="hidden" />
926961<style type="text/css" media="projection" id="slideProj">
src/wrappers/common.sh → wrappers/common.shrenamed

The content is the same.

src/wrappers/hsmarkdown.in → wrappers/hsmarkdown.inrenamed

The content is the same.

src/wrappers/html2markdown.in → wrappers/html2markdown.inrenamed

The content is the same.

src/wrappers/markdown2pdf.in → wrappers/markdown2pdf.inrenamed

The content is the same.

src/wrappers/tempdir.sh → wrappers/tempdir.shrenamed

The content is the same.