diff options
-rw-r--r-- | README | 98 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 15 |
2 files changed, 77 insertions, 36 deletions
@@ -1268,11 +1268,12 @@ and ConTeXt. Producing HTML slide shows with Pandoc ====================================== -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.) +You can use Pandoc to produce an HTML + javascript slide presentation +that can be viewed via a web browser. There are two ways to do this, +using [S5] or [Slidy]. + +Using S5 +-------- Here's the markdown source for a simple slide show, `eating.txt`: @@ -1292,15 +1293,69 @@ 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 + pandoc -w s5 -s eating.txt > eating.html -for Slidy, or +A title page is constructed automatically from the document's title +block. 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.) + +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. + +Using Slidy +----------- + +If you use Slidy, things work a bit differently. Instead of +automatically chopping the document into sections on the level-1 +headers, you can choose how to segment the document into slides +yourself. Just insert a horizontal rule at each slide boundary. +For example: - pandoc -w s5 -s eating.txt > eating.html + % Eating Habits + % John Doe + % March 22, 2005 -for S5. + # In the morning + + - Eat eggs + - Drink coffee + + ----------------------------------------- -and open up `eating.html` in a browser. + # In the evening + + - Eat spaghetti + - Drink wine + + ------------------------------------------ + + The end! + +To produce the slide show, simply type + + pandoc -w slidy -s eating.txt > eating.html + +Incremental lists +----------------- Note that by default, these writers produces lists that display "all at once." If you want your lists to display incrementally @@ -1315,29 +1370,6 @@ 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. -Notes on S5: - -- 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 ======================== diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index cd03a51b5..3f9a417d2 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -104,7 +104,17 @@ pandocToHtml opts (Pandoc (Meta title' authors' date') blocks) = do toc <- if writerTableOfContents opts then tableOfContents opts sects else return Nothing - blocks' <- liftM toHtmlFromList $ mapM (elementToHtml opts) sects + let cutUp (HorizontalRule : xs) = RawHtml "</div>\n<div class=\"slide\">\n" : + cutUp xs + cutUp (x:xs) = x : cutUp xs + cutUp [] = [] + blocks' <- liftM toHtmlFromList $ + case writerSlideVariant opts of + SlidySlides -> mapM (blockToHtml opts) $ + RawHtml "<div class=\"slide\">\n" : + cutUp blocks ++ + [RawHtml "</div>"] + _ -> mapM (elementToHtml opts) sects st <- get let notes = reverse (stNotes st) let thebody = blocks' +++ footnoteSection notes @@ -199,8 +209,7 @@ elementToHtml opts (Sec level num id' title' elements) = do header' <- blockToHtml opts (Header level title') let stuff = header' : innerContents return $ case writerSlideVariant opts of - SlidySlides | level == 1 -> - thediv ! [prefixedId opts id', theclass "slide"] << stuff + SlidySlides -> toHtmlFromList stuff S5Slides -> toHtmlFromList stuff -- S5 gets confused by the extra divs around sections _ | (writerStrictMarkdown opts && |