alte Skripte rausgeworfen
mod_html_files nach documents verschoben
This commit is contained in:
parent
c4b03cd0ae
commit
762e1e23d5
6 changed files with 1 additions and 164 deletions
|
@ -51,7 +51,7 @@ $(HTML_FILES): %.html: %.tex
|
|||
-rm _output/$(notdir $(basename $@)).css 2>/dev/null
|
||||
-rm _output/images.aux _output/images.log _output/images.out _output/images.pl _output/images.text _output/img?.old _output/labels.pl _output/missfont.log _output/images.tex 2>/dev/null
|
||||
mv _output/$(shell dirname $@).html $@
|
||||
python ../convert-scripts/mod_html_files.py $@
|
||||
python mod_html_files.py $@
|
||||
|
||||
|
||||
clean:
|
||||
|
|
76
documents/mod_html_files.py
Normal file
76
documents/mod_html_files.py
Normal file
|
@ -0,0 +1,76 @@
|
|||
#!/usr/bin/env python
|
||||
'''gets a latex2html file and returns the file with a css tag
|
||||
and stuff'''
|
||||
import string
|
||||
import sys
|
||||
import re
|
||||
|
||||
|
||||
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()
|
||||
#zu_manipulierende_variable=string.replace(zu_manipulierende_variable,alter_string,neuer_string)
|
||||
content=string.replace(content,'Table of Contents','Inhalt')
|
||||
# now cut off the hevea footer:
|
||||
footer="""<HR SIZE=2>
|
||||
<BLOCKQUOTE><EM>This document was translated from L<sup>A</sup>T<sub>E</sub>X by
|
||||
</EM><A HREF="http://pauillac.inria.fr/~maranget/hevea/index.html"><EM>H<FONT SIZE=2><sup>E</sup></FONT>V<FONT SIZE=2><sup>E</sup></FONT>A</EM></A><EM>.
|
||||
</EM></BLOCKQUOTE>"""
|
||||
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,'<FONT SIZE=5>','')
|
||||
content = string.replace(content,'</FONT>','')
|
||||
|
||||
#recently switched to latex2html, now cutting of headers
|
||||
startoffset=string.find(content,"<HR>\n<ADDRESS>")
|
||||
endoffset=string.find(content,"</ADDRESS>",startoffset)+len("</ADDRESS>")
|
||||
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")
|
||||
|
||||
#delete everything till <body> tag
|
||||
content = content[string.find(content,"<BODY >"):]
|
||||
|
||||
#put whole content into div tags
|
||||
content = string.replace(content,"<BODY >",'<!-- main starts here -->\n<div id="main">')
|
||||
content = string.replace(content,"</BODY>",'</div>')
|
||||
content = string.replace(content,"</HTML>",'<!-- end of main -->')
|
||||
|
||||
#remove empty image subtitles
|
||||
content = string.replace(content,"<STRONG>Figure:</STRONG>","")
|
||||
|
||||
#all done, writing tuned files
|
||||
writeFile(content,sys.argv[1])
|
||||
|
||||
except: #read/write/whatever failed,
|
||||
# BOESE: unklare Fehlerbehandlung
|
||||
print "an defined error occured - but i'm too lame to fix that"
|
||||
print "usage:",sys.argv[0],"<file_to_modify>"
|
||||
sys.exit(1)
|
||||
sys.exit(0)
|
Loading…
Add table
Add a link
Reference in a new issue