#!/usr/bin/ruby

require 'yaml'
require 'pp'

root = YAML::load_file(ARGV[0])
doc = root['doc']

puts "<html>"
puts " <head>"
puts "  <title>#{doc['title']}</title>"
puts "  <link rel='stylesheet' type='text/css' href='style.css'/>"
puts " </head>"
puts " <body>"
puts "  <h1>#{doc['title']}</h1>"
puts "  <div class='author'>#{doc['author']}</div>"
puts "  <div class='date'>#{doc['date']}</div>"
doc.keys.grep(/^section/).sort.each do |key|
  section = doc[key]
  puts "  <div class='section'>"
  puts "   <h2>#{section['title']}</h2>"
  puts "   <p>#{section['text']}</p>"
  puts "  </div>"
end
puts " </body>"
puts "</html>"
