Platinum Partner

Code 2 HTML

This is a simple python program that reads a file (code), and replaces line breaks and spaces with appropriate tag and entity.


import sys

line_break='
' nb_space=' ' def toHtml(f,out): try: fo=open(out,'w') except IOError: print 'output file error!' else: for line in f: line=line.replace('\t',nb_space*8) line=line.replace(' ',nb_space) line=line.replace('\n',line_break) fo.write(line) fo.close() if len(sys.argv) == 1: print("at least one argument / input filename / required") sys.exit() if len(sys.argv) > 3: print"too many arguments" sys.exit() try: f=open(sys.argv[1],'r') except IOError: print 'cannot open file ', sys.argv[1] else: if len(sys.argv) == 2: out=f.name + '.html' else: out=sys.argv[2] toHtml(f, out) f.close()
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}