python source -> html
François Pinard
pinard at iro.umontreal.ca
Sat Dec 14 12:08:38 EST 2002
[Achim Domma]
> I'm looking for a tool, which converts python source code to html, to show
> examples on a webpage. Any idea?
I use `enscript' for this. Let me see... Yes:
[...]
before = True
for line in os.popen('enscript -p- -Whtml -G -E%s %s'
% (language or '', name)):
if before:
if line == '<PRE>\n':
before = False
continue
if line == '</PRE>\n':
break
write(line)
[...]
LANGUAGE is 'python' and NAME is the file name of the source. The code
above extracts what is between `<PRE>' and `</PRE>', but you might be happy
with the whole output.
--
François Pinard http://www.iro.umontreal.ca/~pinard
More information about the Python-list
mailing list