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 fromstart
up toend
tokenize_source_code(source, tokenizer)
— generator, yielding tokens fromsourcecode
, provided withtokenizer
html_highlight(classified_text)
— generates html formatted text fromclassified_text
tokensgenerate_html_page(classified_text, title)
— generates full html page fromclassified_text
tokens and addstitle
into it
Token type constants.
Small script using utils to convert data from nroff into html format.