Skip to content

Instantly share code, notes, and snippets.

@colin
Created October 9, 2009 09:49
Show Gist options
  • Save colin/205894 to your computer and use it in GitHub Desktop.
Save colin/205894 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'rubygems'
require 'nokogiri'
require 'cgi'
zipfile = ARGV[0]
`mkdir /tmp/keycutter`
`cp #{zipfile} /tmp/keycutter/keycutter.zip`
`cd /tmp/keycutter && unzip -o keycutter.zip`
doc = Nokogiri::XML(open('/tmp/keycutter/index.apxl'))
slides = []
doc.xpath('//key:slide').each do |slide|
data = ""
slide.xpath('key:notes//sf:p').each do |notes_para|
data += notes_para.text + " \n"
end
slides << data
end
File.open("output.html","w") do |f|
f.puts "<html>
<head>
<style>
.note {
border:2px solid black;
padding:3px;
margin:3px;
width:30%;
height:7.2cm;
float:left;
font-size:9pt;
overflow:hidden;
}
.noteid {
font-size:14pt;
font-weight:bold;
float:right;
}
.breaker {
page-break-before:always;
height:2px;
clear:both;
}
</style>
</head>
<body>"
count = 1
slides.each do |data|
f.puts "<div class='note'><div class='noteid'>#{count}</div>"
f.puts CGI.escapeHTML(data).gsub("\n","<br/>")
f.puts "</div>"
f.puts "<div class='breaker'>&nbsp;</div>" if (count % 9) == 0
count += 1
end
f.puts "</body>"
puts "Wrote #{count-1} slides"
end
`open output.html`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment