#!/usr/bin/env python '''gets a latex2html file and returns the file with a css tag and stuff''' import string import sys def writeFile(data, filename): """ write data to the given filename @param filename String : name of file to write to """ try: f = open(filename,"w")#oeffnen und schliessen => f.close() #datei ist jetzt genullt f = open(filename,"a") #anhaengend oeffnen f.write(data) f.close() return "" except: print "(WW)[%s]: \"%s\" is not writeable!"%(__name__, filename) return filename ### start of code try: f=open(sys.argv[1],"r") content=f.read() f.close() if string.find(content,'''REL="stylesheet"''')<0:#if file is unmodified: old='' new='''\n\n''' content=string.replace(content,old,new)#insert css tag content=string.replace(content,'Table of Contents','Inhalt') # now cut off the hevea footer: footer="""
This document was translated from LATEX by HEVEA.
""" content=string.replace(content,footer,"") #hevea inserts font tags, and #we don't want none fuken redneck messin wid our stylez!!@!#$!!1 content = string.replace(content,'','') content = string.replace(content,'','') #recently switched to latex2html, now cutting of headers startoffset=string.find(content,"
\n
") endoffset=string.find(content,"
",startoffset)+len("") if (startoffset >10) and (endoffset>startoffset): footer=content[startoffset:endoffset] content=string.replace(content,footer,"") #rename footnotes into Fussnoten content = string.replace(content,"Footnotes","Fu\xdfnoten") #rename content into Inhalt content = string.replace(content,"Contents","Inhalt") #put whole content into div tags content = string.replace(content,"",'
') content = string.replace(content,"",'
') #all done, writing tuned files writeFile(content,sys.argv[1]) except: #read/write/whatever failed, print "usage:",sys.argv[0],"" sys.exit(1) sys.exit(0)