#!/usr/bin/perl -w # # Add the notes from the talk to the HTML slides. # # $Cambridge: hermes/doc/talks/munghtml.pl,v 1.2 2004/01/15 12:57:24 fanf2 Exp $ use strict; open TALK, "talk.mgp" or die "open talk.mgp: $!\n"; sub getnotes { my @notes; my $line; for (;;) { $line = ; last if not defined $line; last if $line =~ m|^%page$|; next unless $line =~ s|^#+\s*||; chomp $line; push @notes, $line; } return @notes; } # discard preliminary gubbins getnotes; my $i = 0; for (;;) { my @notes = getnotes; last unless @notes; my $mgp = sprintf "mgp%05d", ++$i; if (not -f "$mgp.old") { rename "$mgp.html", "$mgp.old" or die "rename $mgp.html to $mgp.old: $!\n"; } open OLD, "< $mgp.old" or die "open $mgp.old: $!\n"; open NEW, "> $mgp.html" or die "open $mgp.html: $!\n"; my $line; for (;;) { $line = ; last if not defined $line; if ($line =~ m|^\\n"; print NEW "\"Page\n"; print NEW "\n"; print NEW map "
$_\n", @notes; } else { print NEW $line; } } close OLD or die "close $mgp.old: $!\n"; close NEW or die "close $mgp.html: $!\n"; } close TALK or die "close talk.mgp: $!\n"; exit 0;