S5 with textile

I’ve started working on a presentation for skillswap. Like any paranoid coder, I want to keep my work under revision control, so I prefer a text based format. Of these, the best option presently seems to be S5. But it does require you to write a fair chunk of HTML. These days though, I prefer textile.

So, I wrote a small standalone textile processor in ruby:

#!/usr/bin/env ruby
require 'rubygems'
require_gem 'RedCloth'

This, combined with a small Makefile lets me build the S5 presentation quite simply from the textile file.

index.html: s5-head.html vc-intro-svn.txt s5-foot.html
        (cat s5-head.html; 
         ./textile vc-intro-svn.txt; 
         cat s5-foot.html) > $@

The only mildly irritating limitation is that you still have to explicitly wrap the slides in <div class='slide'>...</div>. But I can live with that.

There was still one thing missing though. If you printed out the presentation, all the links wouldn’t show up. Because textile outputs well formed xhtml, it was a simple matter to use a small bit of XSLT to harvest the links on each slide and insert a handout div listing them.

<xsl:stylesheet version="1.0"
  <xsl:output omit-xml-declaration="yes"/>
  <xsl:template match="@* | node()">
      <xsl:apply-templates select="@* | node()"/>
  <xsl:template match="div[@class='slide']">
    <div class="slide">
      <xsl:if test=".//a">
        <div class="handout">
          <p>Links from the slide:</p>
            <xsl:for-each select=".//a">
                <xsl:value-of select="."/>
                <xsl:text>: </xsl:text>
                <a href="{@href}"><xsl:value-of select="@href"/></a>

Like all XSLT, it looks more verbose than it actually is (something it shares with Java, IMHO). But it serves a useful purpose. Now, the printed slides aren’t lacking in information.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s