Simple console application (written for my university python course) for translating some language source code into html-highlighted code by some patterns.
Translates some language (python / C / bash) source code into html-highlighted code by using some patterns.
main.py [-h] [-b] [-l {python,bash,c}] [-d] sourcefile outputfile
./main.py main.py main.py.html
-h/--help— show help-b/--browser— open html in default browser-l {python,bash,c}/--language {python,bash,c}— manually select language-d/--debug— run script in debug modesourcefile— source fileoutputfile— output file
Subsidiary functions.
_combine_range(lines, start, end)— combines lines and text in lines into one string fromstartup toendtokenize_source_code(source, tokenizer)— generator, yielding tokens fromsourcecode, provided withtokenizerhtml_highlight(classified_text)— generates html formatted text fromclassified_texttokensgenerate_html_page(classified_text, title)— generates full html page fromclassified_texttokens and addstitleinto it
Token type constants.
Small script using utils to convert data from nroff into html format.