The Format class is accessible via the kid module.
Create an output format with given parameters.
You can pass one or more text filter functions for processing text content in the output stream.
You can also set keyword parameters for using some standard text filter operations. The following parameters must be set to True to activate the operation:
strip_lines: strip blanks in all text lines lstrip_lines: left strip blanks in all text lines rstrip_lines: right strip blanks in all text lines simple_blanks: remove all duplicate blanks no_empty_lines: remove all empty lines simple_whitespace: remove all duplicate whitespace wrap: wrap text lines to a maximum width
You can also specify the exact width using the wrap parameter.
There are some more operations which you should use with caution, since they may remove significant whitespace:
strip: strip whitespace lstrip: left strip whitespace rstrip: right strip whitespace strip_blanks: strip blanks lstrip_blanks: left strip blanks rstrip_blanks: right strip blanks
The following parameters control typographic punctuation.
educate_quotes: use typographic quotes educate_backticks: replace backticks with opening quotes educate_dashes: replace en-dashes and em-dashes educate_ellipses: replace ellipses educate (or nice): all of the above stupefy (or ugly): reverse operation of educate
apostrophe: character to be used for the apostrophe squotes: left and right single quote characters dquotes: left and right double quote characters dashes: characters to be used for en-dash and em-dash ellipsis: character to be used for the ellipsis
The following parameters control indentation. This will insert newlines and level-dependent indentation, paying regard to inline and whitespace senstive tags:
indent: string or number of blanks for indentation min_level: minimum level for indentation max_level: maximum level for indentation
Note that this formatting has some limitations since it processes only text content in a stream (no look-ahead, no paying regard to the format of the serialized tags).
The following parameters are passed to the Serializer (see there for the possible values of these parameters):
decl: add xml declaration at the beginning doctype: add document type at the beginning entity_map (or named): entity map for named entities transpose: how to transpose html tags inject_type: inject meta tag with content-type
See the source for more information.