new_contents: #!/usr/bin/env python
  
  import string
  
  class htmlthing:
  	'''handle writing out a simple formatted html file'''
  	def __init__(self,filename):
  		self.filename = filename
  		self.title = ""
  		self.starts = { 'pre': "<pre>", 'normal': "<p>\n", 'h1': "\n<h1>", 'h2': "<h2>" }
  		self.ends = { 'pre' : "</pre>\n", 'normal': "</p>\n", 'h1': "</h1>\n", 'h2': "</h2>\n" }
  		self.state = 'none'
  	def set_title(self, title):
  		self.title = title
  	def open(self):
  		self.file = open(self.filename, 'w')
  		self.write_header()
  	def close(self):
  		self.write_footer()
  		self.file.close()
  	def write_header(self):
  		self.file.write("<html>\n<head>\n")
  		if self.title:
  			self.file.write("<title>" + self.title + "</title>\n")
  		self.file.write("<!-- generated by spec2html from source -->\n")
  		self.file.write("</head>\n<body>\n")
  	def write_footer(self):
  		self.file.write("\n</body>\n</html>\n")
  	def close_group(self):
  		if self.state != 'none':
  			self.file.write(self.ends[self.state])
  			self.state = 'none'
  	def set_state(self, state):
  		if self.state != state:
  			self.close_group()
  			self.file.write(self.starts[state])
  			self.state = state
  	def write(self, line):
  		self.file.write(line)
  
  spec = open('spec.py', 'r')
  html = htmlthing('spec.html')
  html.open()
  blank_count = 0;
  while True:
  	line = spec.readline()
  	if line == '': break
  	if line == '\n':
  		html.close_group()
  		blank_count += 1
  	else:
  		if line[:1] == '#':
  			if line[:4] == '#   ':
  				html.set_state('pre')
  			elif line[:3] == '##_':
  				html.set_state('h1')
  				line = line[:1] + line[3:-1]
  			elif blank_count > 1:
  				html.set_state('h2')
  				line = string.strip(line)
  			else:
  				html.set_state('normal')
  			html.write(line[1:])
  		else:
  			html.set_state('pre')
  			html.write(line)
  		blank_count = 0
  html.close()
  spec.close()
  
subject: Add a quick script to generate spec.html from spec.py. Dan claims to have used such a script for the original version, but I can't figure out what some of the formatting keys are, so this isn't turned on yet. We should use Restructured Text anyway.