.. _f-py2html: module ``homeblog.py2html`` =========================== Short summary +++++++++++++ module ``ensae_teaching_cs.homeblog.py2html`` Mark-up Python code file using HTML for syntax highlighting. Syntax highlighting rules are in the spirit of IDLE. Unless the -r 0 option is used it will also format the code by applying some of the PEP8 spacing guidelines to expressions and assignments. For those that want a GUI you can try py2htmTk.pyw - (it's minimal but functional). :: USAGE in command line mode: py2html [options] [-i filename]|-I] OPTIONS: -h Print this command line summary --help Print more detailed help on styles and revision info. -o filename Output file (default is "py2html.html") -i filename Source file. See -I. -p filename HTML page template (must include a %s for inserting the code). If not specified then a default is used. -s filename Use a style-file otherwise use built in styles (see --help for details) -r 0|1|2 Reformat expressions and definitions. -r 0 No formatting -r 1 Format as a = 3+4; b = [1, 2, 3] (default) -r 2 Format as a = 3 + 4; b = [1 , 2 , 3] -R Replace newlines with
, tabs and multi-spaces with   -B Just make a block (ignores -p) -O Print to sys.stdout (ignores -o, no file created) -I Use stdin as source file (ignore -i option) -E 0|1|2|3|4 0 - Don't do entity substitution. 1 - Substitute < > and & (default) 2 - Substitute < > & and " 3 - Substitute <> & " and ' 4 - Substitute all non-ASCIIalphanumeric :githublink:`%|py|42` Functions +++++++++ +------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+ | function | truncated documentation | +====================================================================================+======================================================================================================================+ | :func:`apply_style ` | Supplied with an index this function applies the style using the format rules and returns a formatted verison of ... | +------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+ | :func:`cmdLine ` | This is the function that handles command line mode | +------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+ | :func:`file2HTML ` | Reads a file and returns the contents as a string, highlighted with :epkg:`HTML` styles. This function uses the ... | +------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+ | :func:`makeBlock ` | Applies the block tags to text | +------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+ | :func:`readStyleFile ` | Read a style file and return a style dictionary. The file format is | +------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+ | :func:`replaceCodes ` | Helper function that does the ``\n`` and space substition returning the changed text. | +------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+ | :func:`substituteEntities ` | based on level setting do entity substitution and return revised. iso8859-1 ??: | +------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+ Documentation +++++++++++++ .. automodule:: ensae_teaching_cs.homeblog.py2html :members: :special-members: __init__ :show-inheritance: