Added a slidy writer.

Resolves Issue #122.
This commit is contained in:
John MacFarlane 2010-07-13 20:44:56 -07:00
parent a59a141906
commit 9b833e8744
7 changed files with 170 additions and 70 deletions

119
README
View file

@ -7,7 +7,9 @@ another, and a command-line tool that uses this library. It can read
[markdown] and (subsets of) [reStructuredText], [HTML], and [LaTeX]; and
it can write plain text, [markdown], [reStructuredText], [HTML], [LaTeX],
[ConTeXt], [RTF], [DocBook XML], [OpenDocument XML], [ODT], [GNU Texinfo],
[MediaWiki markup], [EPUB], [groff man] pages, and [S5] HTML slide shows.
[MediaWiki markup], [EPUB], [groff man] pages, and [Slidy] or [S5]
HTML slide shows.
Pandoc's enhanced version of markdown includes syntax for footnotes,
tables, flexible ordered lists, definition lists, delimited code blocks,
superscript, subscript, strikeout, title blocks, automatic tables of
@ -25,6 +27,7 @@ or output format requires only adding a reader or writer.
[markdown]: http://daringfireball.net/projects/markdown/
[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
[S5]: http://meyerweb.com/eric/tools/s5/
[Slidy]: http://www.w3.org/Talks/Tools/Slidy/
[HTML]: http://www.w3.org/TR/html40/
[LaTeX]: http://www.latex-project.org/
[ConTeXt]: http://www.pragma-ade.nl/
@ -92,8 +95,8 @@ Supported output formats include `markdown`, `latex`, `context`
(reStructuredText), `docbook` (DocBook XML), `opendocument`
(OpenDocument XML), `odt` (OpenOffice text document), `texinfo`, (GNU
Texinfo), `mediawiki` (MediaWiki markup), `epub` (EPUB ebook),
`man` (groff man), and `s5`
(which produces an HTML file that acts like powerpoint).
`man` (groff man), `slidy` (slidy HTML and javascript slide show), or
`s5` (S5 HTML and javascript slide show).
Supported input formats include `markdown`, `html`, `latex`, and `rst`.
Note that the `rst` reader only parses a subset of reStructuredText
@ -191,7 +194,7 @@ For further documentation, see the `pandoc(1)` man page.
`-t`, `--to`, `-w`, or `--write` *format*
: specifies the output format -- the format Pandoc will
be converting *to*. *format* can be `native`, `html`, `s5`,
be converting *to*. *format* can be `native`, `html`, `slidy`, `s5`,
`docbook`, `opendocument`, `latex`, `context`, `markdown`, `man`,
`plain`, `rst`, and `rtf`. (`+lhs` can be appended to indicate that
the output should be treated as literate Haskell source. See
@ -228,11 +231,12 @@ For further documentation, see the `pandoc(1)` man page.
`-R` or `--parse-raw`
: causes the HTML and LaTeX readers to parse HTML codes and LaTeX
environments that it can't translate as raw HTML or LaTeX. Raw HTML can
be printed in markdown, reStructuredText, HTML, and S5 output; raw LaTeX
can be printed in markdown, reStructuredText, LaTeX, and ConTeXt output.
The default is for the readers to omit untranslatable HTML codes and
LaTeX environments. (The LaTeX reader does pass through untranslatable
LaTeX *commands*, even if `-R` is not specified.)
be printed in markdown, reStructuredText, HTML, Slidy, and S5
output; raw LaTeX can be printed in markdown, reStructuredText,
LaTeX, and ConTeXt output. The default is for the readers to omit
untranslatable HTML codes and LaTeX environments. (The LaTeX reader
does pass through untranslatable LaTeX *commands*, even if `-R` is
not specified.)
`-C` or `--custom-header` *filename*
: can be used to specify a custom document header. Implies `--standalone`.
@ -242,7 +246,7 @@ For further documentation, see the `pandoc(1)` man page.
: includes an automatically generated table of contents (or, in the
case of `latex`, `context`, and `rst`, an instruction to create
one) in the output document. This option has no effect with `man`,
`docbook`, or `s5` output formats.
`docbook`, `slidy`, or `s5` output formats.
`--base-header-level` *level*
: specifies the base level for headers (defaults to 1).
@ -263,9 +267,9 @@ For further documentation, see the `pandoc(1)` man page.
`-c` or `--css` *filename*
: allows the user to specify a custom stylesheet that will be linked to
in HTML and S5 output. This option can be used repeatedly to include
multiple stylesheets. They will be included in the order specified.
Implies `--standalone`.
in HTML, Slidy, and S5 output. This option can be used repeatedly
to include multiple stylesheets. They will be included in the order
specified. Implies `--standalone`.
`-H` or `--include-in-header` *filename*
: includes the contents of *filename* (verbatim) at the end of the
@ -340,13 +344,13 @@ For further documentation, see the `pandoc(1)` man page.
`-m`*[url]* or `--latexmathml`*[=url]*
: causes `pandoc` to use the [LaTeXMathML] script to display
TeX math in HTML or S5. If a local copy of `LaTeXMathML.js` is
available on the webserver where the page will be viewed, provide a
*url* and a link will be inserted in the generated HTML or S5. If
TeX math in HTML, Slidy, or S5. If a local copy of `LaTeXMathML.js`
is available on the webserver where the page will be viewed, provide
a *url* and a link will be inserted in the generated HTML. If
no *url* is provided, the contents of the script will be inserted
directly; this provides portability at the price of efficiency. If
you plan to use math on several pages, it is much better to link to
a copy of `LaTeXMathML.js`, which can be cached. (See `--jsmath`,
a copy of `LaTeXMathML.js`, which can be cached. (See `--jsmath`,
`--gladtex`, and `--mimetex` for alternative ways of dealing with
math in HTML.)
@ -357,17 +361,18 @@ For further documentation, see the `pandoc(1)` man page.
`--jsmath`*=[url]*
: causes `pandoc` to use the [jsMath] script to display
TeX math in HTML or S5. The *url* should point to the jsMath load
script (e.g. `jsMath/easy/load.js`). If it is provided, a link to it
will be included in the header of standalone HTML documents.
TeX math in HTML, Slidy, or S5. The *url* should point to the jsMath
load script (e.g. `jsMath/easy/load.js`). If it is provided, a link
to it will be included in the header of standalone HTML documents.
(See `--latexmathml`, `--mimetex`, and `--gladtex` for alternative
ways of dealing with math in HTML.)
`--gladtex`*[=url]*
: causes TeX formulas to be enclosed in `<eq>` tags in HTML or S5 output.
This output can then be processed by [gladTeX] to produce links to
images with the typeset formulas. (See `--latexmathml`, `--jsmath`, and
`--mimetex` for alternative ways of dealing with math in HTML.)
: causes TeX formulas to be enclosed in `<eq>` tags in HTML, Slidy, or
S5 output. This output can then be processed by [gladTeX] to produce
links to images with the typeset formulas. (See `--latexmathml`,
`--jsmath`, and `--mimetex` for alternative ways of dealing with
math in HTML.)
`--mimetex`*[=url]*
: causes TeX formulas to be replaced by `<img>` tags linking to the
@ -376,7 +381,7 @@ For further documentation, see the `pandoc(1)` man page.
ways of dealing with math in HTML.)
`-i` or `--incremental`
: causes all lists in S5 output to be displayed incrementally by
: causes all lists in Slidy or S5 output to be displayed incrementally by
default (one item at a time). The normal default is for lists to be
displayed all at once.
@ -1200,7 +1205,7 @@ Unknown commands and symbols, and commands that cannot be dealt with
this way (like `\frac`), will be rendered verbatim. So the results may
be a mix of raw TeX code and properly rendered unicode math.
In HTML and S5 output, the way math is rendered will depend on the
In HTML, Slidy, and S5 output, the way math is rendered will depend on the
command-line options selected:
1. The default is to render TeX math as far as possible using unicode
@ -1260,14 +1265,14 @@ LaTeX, not as markdown.
Inline LaTeX is ignored in output formats other than Markdown, LaTeX,
and ConTeXt.
Producing S5 with Pandoc
========================
Producing HTML slide shows with Pandoc
======================================
Producing an [S5] web-based slide show with Pandoc is easy. A title
page is constructed automatically from the document's title block (see
above). Each section (with a level-one header) produces a single slide.
(Note that if the section is too big, the slide will not fit on the page;
S5 is not smart enough to produce multiple pages.)
Producing a [Slidy] or [S5] web-based slide show with Pandoc is easy. A
title page is constructed automatically from the document's title block
(see above). Each section (with a level-one header) produces a single
slide. (Note that if the section is too big, the slide will not fit on
the page; S5 is not smart enough to produce multiple pages.)
Here's the markdown source for a simple slide show, `eating.txt`:
@ -1287,11 +1292,17 @@ Here's the markdown source for a simple slide show, `eating.txt`:
To produce the slide show, simply type
pandoc -w slidy -s eating.txt > eating.html
for Slidy, or
pandoc -w s5 -s eating.txt > eating.html
for S5.
and open up `eating.html` in a browser.
Note that by default, the S5 writer produces lists that display
Note that by default, these writers produces lists that display
"all at once." If you want your lists to display incrementally
(one item at a time), use the `-i` option. If you want a
particular list to depart from the default (that is, to display
@ -1304,26 +1315,28 @@ incrementally without the `-i` option and all at once with the
In this way incremental and nonincremental lists can be mixed in
a single document.
Note: the S5 file produced by pandoc with the `-s/--standalone` option
embeds the javascript and CSS required to show the slides. Thus it
does not depend on any additional files: you can send the HTML file to
others, and they will be able to view the slide show just by opening
it. However, if you intend to produce several S5 slide shows, and you
are displaying them on your own website, it is better to keep the S5
javascript and CSS files separate from the slide shows themselves, so
that they may be cached. The best approach in this case is to use pandoc
without the `-s` option to produce the body of the S5 document, which
can then be inserted into an HTML template that links to the javascript
and CSS files required by S5. (See the instructions on the S5 website.)
Alternatively, you may use `-s` together with the `--template`
option to specify a custom template.
Notes on S5:
You can change the style of the slides by putting customized CSS files
in `$DATADIR/s5/default`, where `$DATADIR` is the user data directory
(see `--data-dir`, above). The originals may be found in pandoc's system
data directory (generally `$CABALDIR/pandoc-VERSION/s5/default`). Pandoc
will look there for any files it does not find in the user data
directory.
- The S5 file produced by pandoc with the `-s/--standalone`
option embeds the javascript and CSS required to show the slides. Thus
it does not depend on any additional files: you can send the HTML file
to others, and they will be able to view the slide show just by opening
it. However, if you intend to produce several S5 slide shows, and you
are displaying them on your own website, it is better to keep the S5
javascript and CSS files separate from the slide shows themselves, so
that they may be cached. The best approach in this case is to use pandoc
without the `-s` option to produce the body of the S5 document, which
can then be inserted into an HTML template that links to the javascript
and CSS files required by S5. (See the instructions on the S5 website.)
Alternatively, you may use `-s` together with the `--template` option to
specify a custom template.
- You can change the style of the slides by putting customized CSS files
in `$DATADIR/s5/default`, where `$DATADIR` is the user data directory
(see `--data-dir`, above). The originals may be found in pandoc's system
data directory (generally `$CABALDIR/pandoc-VERSION/s5/default`). Pandoc
will look there for any files it does not find in the user data
directory.
Literate Haskell support
========================

View file

@ -16,7 +16,7 @@ Pandoc converts files from one markup format to another. It can
read markdown and (subsets of) reStructuredText, HTML, and LaTeX, and
it can write plain text, markdown, reStructuredText, HTML, LaTeX,
ConTeXt, Texinfo, groff man, MediaWiki markup, RTF, OpenDocument XML,
ODT, DocBook XML, EPUB, and S5 HTML slide shows.
ODT, DocBook XML, EPUB, and Slidy or S5 HTML slide shows.
If no *input-file* is specified, input is read from *stdin*.
Otherwise, the *input-files* are concatenated (with a blank
@ -75,6 +75,7 @@ should pipe input and output through `iconv`:
`mediawiki` (MediaWiki markup), `texinfo` (GNU Texinfo),
`docbook` (DocBook XML), `opendocument` (OpenDocument XML),
`odt` (OpenOffice text document), `epub` (EPUB book),
`slidy` (Slidy HTML and javascript slide show),
`s5` (S5 HTML and javascript slide show), or `rtf` (rich text
format). Note that `odt` and `epub` output will not be directed to
*stdout*; an output filename must be specified using the `-o/--output`
@ -136,7 +137,7 @@ should pipe input and output through `iconv`:
it is assumed that the script is at `/cgi-bin/mimetex.cgi`.
-i, \--incremental
: Make list items in S5 display incrementally (one by one).
: Make list items in Slidy or S5 display incrementally (one by one).
\--xetex
: Create LaTeX outut suitable for processing by XeTeX.
@ -175,7 +176,7 @@ should pipe input and output through `iconv`:
\--toc, \--table-of-contents
: Include an automatically generated table of contents (HTML, markdown,
RTF) or an instruction to create one (LaTeX, reStructuredText).
This option has no effect on man, DocBook, or S5 output.
This option has no effect on man, DocBook, Slidy, or S5 output.
\--base-header-level=*LEVEL*
: Specify the base level for headers (defaults to 1).

View file

@ -42,6 +42,7 @@ Data-Files:
templates/man.template, templates/markdown.template,
templates/rst.template, templates/plain.template,
templates/mediawiki.template, templates/rtf.template,
templates/slidy.template,
-- data for ODT writer
reference.odt,
-- stylesheet for EPUB writer

View file

@ -66,6 +66,7 @@ module Text.Pandoc.Shared (
-- * Writer options
HTMLMathMethod (..),
ObfuscationMethod (..),
HTMLSlideVariant (..),
WriterOptions (..),
defaultWriterOptions,
-- * File handling
@ -466,6 +467,12 @@ data ObfuscationMethod = NoObfuscation
| JavascriptObfuscation
deriving (Show, Read, Eq)
-- | Varieties of HTML slide shows.
data HTMLSlideVariant = S5Slides
| SlidySlides
| NoSlides
deriving (Show, Read, Eq)
-- | Options for writers
data WriterOptions = WriterOptions
{ writerStandalone :: Bool -- ^ Include header and footer
@ -474,11 +481,11 @@ data WriterOptions = WriterOptions
, writerEPUBMetadata :: String -- ^ Metadata to include in EPUB
, writerTabStop :: Int -- ^ Tabstop for conversion btw spaces and tabs
, writerTableOfContents :: Bool -- ^ Include table of contents
, writerS5 :: Bool -- ^ We're writing S5
, writerSlideVariant :: HTMLSlideVariant -- ^ Are we writing S5 or Slidy?
, writerIncremental :: Bool -- ^ True if lists should be incremental
, writerXeTeX :: Bool -- ^ Create latex suitable for use by xetex
, writerHTMLMathMethod :: HTMLMathMethod -- ^ How to print math in HTML
, writerIgnoreNotes :: Bool -- ^ Ignore footnotes (used in making toc)
, writerIncremental :: Bool -- ^ Incremental S5 lists
, writerNumberSections :: Bool -- ^ Number sections in LaTeX
, writerStrictMarkdown :: Bool -- ^ Use strict markdown syntax
, writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
@ -499,11 +506,11 @@ defaultWriterOptions =
, writerEPUBMetadata = ""
, writerTabStop = 4
, writerTableOfContents = False
, writerS5 = False
, writerSlideVariant = NoSlides
, writerIncremental = False
, writerXeTeX = False
, writerHTMLMathMethod = PlainMath
, writerIgnoreNotes = False
, writerIncremental = False
, writerNumberSections = False
, writerStrictMarkdown = False
, writerReferenceLinks = False

View file

@ -197,10 +197,16 @@ elementToHtml opts (Sec level num id' title' elements) = do
innerContents <- mapM (elementToHtml opts) elements
modify $ \st -> st{stSecNum = num} -- update section number
header' <- blockToHtml opts (Header level title')
return $ if writerS5 opts || (writerStrictMarkdown opts && not (writerTableOfContents opts))
-- S5 gets confused by the extra divs around sections
then toHtmlFromList (header' : innerContents)
else thediv ! [prefixedId opts id'] << (header' : innerContents)
let stuff = header' : innerContents
return $ case writerSlideVariant opts of
SlidySlides | level == 1 ->
thediv ! [prefixedId opts id', theclass "slide"] << stuff
S5Slides -> toHtmlFromList stuff
-- S5 gets confused by the extra divs around sections
_ | (writerStrictMarkdown opts &&
not (writerTableOfContents opts)) ->
toHtmlFromList stuff
_ -> thediv ! [prefixedId opts id'] << stuff
-- | Convert list of Note blocks to a footnote <div>.
-- Assumes notes are sorted.
@ -296,7 +302,7 @@ blockToHtml opts (BlockQuote blocks) =
-- in S5, treat list in blockquote specially
-- if default is incremental, make it nonincremental;
-- otherwise incremental
if writerS5 opts
if writerSlideVariant opts /= NoSlides
then let inc = not (writerIncremental opts) in
case blocks of
[BulletList lst] -> blockToHtml (opts {writerIncremental = inc})

View file

@ -32,7 +32,7 @@ module Main where
import Text.Pandoc
import Text.Pandoc.Writers.S5 (s5HeaderIncludes)
import Text.Pandoc.Shared ( tabFilter, ObfuscationMethod (..), readDataFile,
headerShift )
headerShift, HTMLSlideVariant(..) )
#ifdef _HIGHLIGHTING
import Text.Pandoc.Highlighting ( languages )
#endif
@ -107,6 +107,7 @@ writers = [("native" , writeNative)
,("html" , writeHtmlString)
,("html+lhs" , writeHtmlString)
,("s5" , writeS5String)
,("slidy" , writeHtmlString)
,("docbook" , writeDocbook)
,("opendocument" , writeOpenDocument)
,("odt" , \_ _ -> "")
@ -142,7 +143,7 @@ data Opt = Opt
, optVariables :: [(String,String)] -- ^ Template variables to set
, optOutputFile :: String -- ^ Name of output file
, optNumberSections :: Bool -- ^ Number sections in LaTeX
, optIncremental :: Bool -- ^ Use incremental lists in S5
, optIncremental :: Bool -- ^ Use incremental lists in Slidy/S5
, optXeTeX :: Bool -- ^ Format latex for xetex
, optSmart :: Bool -- ^ Use smart typography
, optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
@ -300,7 +301,7 @@ options =
, Option "i" ["incremental"]
(NoArg
(\opt -> return opt { optIncremental = True }))
"" -- "Make list items display incrementally in S5"
"" -- "Make list items display incrementally in Slidy/S5"
, Option "" ["xetex"]
(NoArg
@ -733,6 +734,11 @@ main = do
then "."
else takeDirectory (head sources)
let slideVariant = case writerName' of
"s5" -> S5Slides
"slidy" -> SlidySlides
_ -> NoSlides
let startParserState =
defaultParserState { stateParseRaw = parseRaw,
stateTabStop = tabStop,
@ -759,10 +765,10 @@ main = do
writerTableOfContents = toc &&
writerName' /= "s5",
writerHTMLMathMethod = mathMethod,
writerS5 = (writerName' == "s5"),
writerSlideVariant = slideVariant,
writerIncremental = incremental,
writerXeTeX = xetex,
writerIgnoreNotes = False,
writerIncremental = incremental,
writerNumberSections = numberSections,
writerStrictMarkdown = strict,
writerReferenceLinks = referenceLinks,

66
templates/slidy.template Normal file
View file

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>$if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
$for(author)$
<meta name="author" content="$author$" />
$endfor$
<meta name="date" content="$date$" />
$if(highlighting)$
<style type="text/css">
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre { margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }
td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
td.sourceCode { padding-left: 5px; }
pre.sourceCode { }
pre.sourceCode span.Normal { }
pre.sourceCode span.Keyword { color: #007020; font-weight: bold; }
pre.sourceCode span.DataType { color: #902000; }
pre.sourceCode span.DecVal { color: #40a070; }
pre.sourceCode span.BaseN { color: #40a070; }
pre.sourceCode span.Float { color: #40a070; }
pre.sourceCode span.Char { color: #4070a0; }
pre.sourceCode span.String { color: #4070a0; }
pre.sourceCode span.Comment { color: #60a0b0; font-style: italic; }
pre.sourceCode span.Others { color: #007020; }
pre.sourceCode span.Alert { color: red; font-weight: bold; }
pre.sourceCode span.Function { color: #06287e; }
pre.sourceCode span.RegionMarker { }
pre.sourceCode span.Error { color: red; font-weight: bold; }
</style>
$endif$
$for(css)$
<link rel="stylesheet" href="$css$" type="text/css" />
$endfor$
<link rel="stylesheet" type="text/css" media="screen, projection, print"
href="http://www.w3.org/Talks/Tools/Slidy/slidy.css" />
$if(math)$
$math$
$endif$
$for(header-includes)$
$header-includes$
$endfor$
<script src="http://www.w3.org/Talks/Tools/Slidy/slidy.js"
charset="utf-8" type="text/javascript"></script>
</head>
<body>
$for(include-before)$
$include-before$
$endfor$
$if(title)$
<div class="slide cover title">
<h1 class="title">$title$</h1>
$for(author)$
<p class="author">$author$</p>
$endfor$
</div>
$endif$
$body$
$for(include-after)$
$include-after$
$endfor$
</body>
</html>