>')])]
def __init__(self,editwin):
self.editwin=editwin
self.text=editwin.text
def idle2html_event(self, event=None):
filetypes = [
("All HTML files", "*.html *.htm", "TEXT"),
("All files", "*"),
]
filename=tkFileDialog.SaveAs(master=self.text,
filetypes=filetypes,
title="Export to HTML",
).show()
if filename:
f=open(filename,'w')
f.write(self.idle2html())
f.close()
def idle2html(self):
"""format tags 2 html
"""
out=['\n']
out.append('\n\nIDLE2HTML\n')
out.append('\n' % __version__)
out.append('\n')
out.append('\n\n')
inside_error=0
for tagname,content,dummy in self.text.dump('1.0',self.text.index('end')):
if tagname=='tagon' and not (content.upper() in ('SYNC','TODO','SEL')):
if not inside_error:
out.append('' % content)
if content.upper() == 'ERROR':
inside_error=1
if tagname=='text':
out.append(cgi.escape(content))
if tagname=='tagoff' and not (content.upper() in ('SYNC','TODO','SEL')):
if content.upper() == 'ERROR':
inside_error=0
if not inside_error:
out.append('')
out.append('
\n\n')
return ''.join(out)