Skip to content
Snippets Groups Projects
tabs.py 993 B
Newer Older
mb's avatar
mb committed
import re

# read from an etherpad
import urllib 
pad = 'http://10.10.161.238/ether/p/encyclopedia/export/txt'
filein = urllib.urlopen(pad)
padname = pad.replace('http://10.10.161.238/ether/p/','')
padname = padname.replace('/export/txt','')
mb's avatar
mb committed

with open("../../stories/tabs-"+padname+".html","w+") as fileout:

	fileout.write('<div id="main">')
mb's avatar
mb committed

	for line in filein: 
		line = re.sub(r"\s{8}", "\t", line)
		m = re.search(r"^\t*", line) # for tabs

		# m = re.search(r"\s{8}", line) # for 8 spaces as 1 tab
		if m:
			tab = len(m.group(0)) + 1
			strtab = str(tab)
		line = line.replace("\t","")
mb's avatar
mb committed

		if '$!' in line:
			line = line.replace('$!','<span class="annotation">')
			line = line+'</span>'
mb's avatar
mb committed

		fontsize = 55/tab
		fontsize = str(fontsize)
		fontsize = str(12); # uncomment to set fixed fontsize 

		fileout.write('<div class="h'+strtab+'" style="font-size:'+fontsize+'px;">'+line+'</div>\n')

	fileout.write("""
		</div>
		""")

mb's avatar
mb committed
	print '*output of '+padname+' written*'

mb's avatar
mb committed
	fileout.close()