* Abbruchbedingung eingefuegt
This commit is contained in:
parent
9510aeaf5c
commit
2c0f819a27
1 changed files with 86 additions and 83 deletions
|
@ -1,83 +1,86 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
'''gets a latex2html file and returns the file with a css tag
|
'''gets a latex2html file and returns the file with a css tag
|
||||||
and stuff'''
|
and stuff'''
|
||||||
import string
|
import string
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
def writeFile(data, filename):
|
def writeFile(data, filename):
|
||||||
"""
|
"""
|
||||||
write data to the given filename
|
write data to the given filename
|
||||||
@param filename String : name of file to write to
|
@param filename String : name of file to write to
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
f = open(filename,"w")#oeffnen und schliessen =>
|
f = open(filename,"w")#oeffnen und schliessen =>
|
||||||
f.close() #datei ist jetzt genullt
|
f.close() #datei ist jetzt genullt
|
||||||
f = open(filename,"a") #anhaengend oeffnen
|
f = open(filename,"a") #anhaengend oeffnen
|
||||||
f.write(data)
|
f.write(data)
|
||||||
f.close()
|
f.close()
|
||||||
return ""
|
return ""
|
||||||
except:
|
except:
|
||||||
print "(WW)[%s]: \"%s\" is not writeable!"%(__name__, filename)
|
print "(WW)[%s]: \"%s\" is not writeable!"%(__name__, filename)
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
|
||||||
### start of code
|
### start of code
|
||||||
try:
|
try:
|
||||||
f=open(sys.argv[1],"r")
|
f=open(sys.argv[1],"r")
|
||||||
content=f.read()
|
content=f.read()
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# zu_manipulierende_variable=string.replace(zu_manipulierende_variable,alter_string,neuer_string)
|
# zu_manipulierende_variable=string.replace(zu_manipulierende_variable,alter_string,neuer_string)
|
||||||
|
|
||||||
# recently switched to latex2html, now cutting of headers
|
# recently switched to latex2html, now cutting of headers
|
||||||
# dieser abschnitt muss ueberarbeitet werden!
|
# dieser abschnitt muss ueberarbeitet werden!
|
||||||
startoffset=string.find(content,"<HR>\n<ADDRESS>")
|
startoffset=string.find(content,"<HR>\n<ADDRESS>")
|
||||||
endoffset=string.find(content,"</ADDRESS>",startoffset)+len("</ADDRESS>")
|
endoffset=string.find(content,"</ADDRESS>",startoffset)+len("</ADDRESS>")
|
||||||
if (startoffset >10) and (endoffset>startoffset):
|
if (startoffset >10) and (endoffset>startoffset):
|
||||||
footer=content[startoffset:endoffset]
|
footer=content[startoffset:endoffset]
|
||||||
content=string.replace(content,footer,"")
|
content=string.replace(content,footer,"")
|
||||||
|
|
||||||
#put whole content into div tags
|
#put whole content into div tags
|
||||||
content = string.replace(content,"<BR><HR>\n\n</BODY>",'</div>')
|
content = string.replace(content,"<BR><HR>\n\n</BODY>",'</div>')
|
||||||
content = string.replace(content,"</HTML>",'<!-- end of main -->')
|
content = string.replace(content,"</HTML>",'<!-- end of main -->')
|
||||||
|
|
||||||
#remove empty image subtitles
|
#remove empty image subtitles
|
||||||
content = string.replace(content,"<STRONG>Abbildung:</STRONG>","")
|
content = string.replace(content,"<STRONG>Abbildung:</STRONG>","")
|
||||||
|
|
||||||
# replace "./filename.png" references with "filename.png"
|
# replace "./filename.png" references with "filename.png"
|
||||||
# (this avoids validation warnings)
|
# (this avoids validation warnings)
|
||||||
content = string.replace(content,'HREF="./','HREF="')
|
content = string.replace(content,'HREF="./','HREF="')
|
||||||
|
|
||||||
# Fussnoten finden und Ende ersetzen
|
# Fussnoten finden und Ende ersetzen
|
||||||
fussnoten = string.find(content,"<BR><HR><H4>Fußnoten</H4>")
|
fussnoten = string.find(content,"<BR><HR><H4>Fußnoten</H4>")
|
||||||
startoffset = string.find(content,"</DL>",fussnoten)
|
startoffset = string.find(content,"</DL>",fussnoten)
|
||||||
endoffset = startoffset + len("</DL>")
|
endoffset = startoffset + len("</DL>")
|
||||||
content = content[:startoffset] + "</DL>\n</div>" + content[endoffset:]
|
if startoffset > 10 and endoffset > 10:
|
||||||
|
content = content[:startoffset] + "</DL>\n</div>" + content[endoffset:]
|
||||||
# Linie vor Fussnoten wird entfernt
|
|
||||||
# Fussnoten bekommen id, damit sie per css formatierbar sind
|
# Linie vor Fussnoten wird entfernt
|
||||||
content = string.replace(content,'<HR><H4>Fußnoten</H4>','\n<div id="footnotes">\n<H4>Fußnoten</H4>')
|
# Fussnoten bekommen id, damit sie per css formatierbar sind
|
||||||
|
content = string.replace(content,'<HR><H4>Fußnoten</H4>','\n<div id="footnotes">\n<H4>Fußnoten</H4>')
|
||||||
# Sonderzeichen in Fussnoten werden ersetzt (Hotfix fuer einen latex2html-Bug)
|
|
||||||
content = string.replace(content,'ä','ä')
|
# Sonderzeichen in Fussnoten werden ersetzt (Hotfix fuer einen latex2html-Bug)
|
||||||
content = string.replace(content,'Ä','Ä')
|
content = string.replace(content,'ä','ä')
|
||||||
content = string.replace(content,'ö','ö')
|
content = string.replace(content,'Ä','Ä')
|
||||||
content = string.replace(content,'Ö','Ö')
|
content = string.replace(content,'ö','ö')
|
||||||
content = string.replace(content,'ü','ü')
|
content = string.replace(content,'Ö','Ö')
|
||||||
content = string.replace(content,'Ü','Ü')
|
content = string.replace(content,'ü','ü')
|
||||||
content = string.replace(content,'ß','ß')
|
content = string.replace(content,'Ü','Ü')
|
||||||
|
content = string.replace(content,'ß','ß')
|
||||||
# externe Links innerhalb von <div id="main"> erhalten eine class
|
|
||||||
content = string.replace(content,'HREF="http:','class="externalLink" href="http:')
|
# externe Links innerhalb von <div id="main"> erhalten eine class
|
||||||
|
content = string.replace(content,'HREF="http:','class="externalLink" href="http:')
|
||||||
#all done, writing tuned files
|
|
||||||
writeFile(content,sys.argv[1])
|
#all done, writing tuned files
|
||||||
|
writeFile(content,sys.argv[1])
|
||||||
except: #read/write/whatever failed,
|
|
||||||
# BOESE: unklare Fehlerbehandlung
|
except: #read/write/whatever failed,
|
||||||
print "an defined error occured - but i'm too lame to fix that"
|
# BOESE: unklare Fehlerbehandlung
|
||||||
print "usage:",sys.argv[0],"<file_to_modify>"
|
print "an defined error occured - but i'm too lame to fix that"
|
||||||
sys.exit(1)
|
print "usage:",sys.argv[0],"<file_to_modify>"
|
||||||
sys.exit(0)
|
sys.exit(1)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue