class HTMLTranslator(writers._html_base.HTMLTranslator):
Known subclasses: docutils.writers.pep_html.HTMLTranslator
, docutils.writers.s5_html.S5HTMLTranslator
The html4css1 writer has been optimized to produce visually compact lists (less vertical whitespace). HTML's mixed content models allow list items to contain "<li><p>body elements</p></li>" or "<li>just text</li>" or even "<li>text<p>and body elements</p>combined</li>", each with different effects. It would be best to stick with strict body elements in list items, but they affect vertical spacing in older browsers (although they really shouldn't). The html5_polyglot writer solves this using CSS2.
Here is an outline of the optimization:
Check for and omit <p> tags in "simple" lists: list items contain either a single paragraph, a nested simple list, or a paragraph followed by a nested simple list. This means that this list can be compact:
- Item 1.
- Item 2.
But this list cannot be compact:
Item 1.
This second paragraph forces space between list items.
Item 2.
In non-list contexts, omit <p> tags on a paragraph if that paragraph is the only child of its parent (footnotes & citations are allowed a label first).
Regardless of the above, in definitions, table cells, field bodies, option descriptions, and list items, mark the first child with 'class="first"' and the last child with 'class="last"'. The stylesheet sets the margins (top & bottom respectively) to 0 for these elements.
The no_compact_lists setting (--no-compact-lists command-line option) disables list whitespace optimization.
Method | depart_address |
Undocumented |
Method | depart_admonition |
Undocumented |
Method | depart_author |
Undocumented |
Method | depart_authors |
Undocumented |
Method | depart_citation |
Undocumented |
Method | depart_citation_reference |
Undocumented |
Method | depart_classifier |
Undocumented |
Method | depart_colspec |
Undocumented |
Method | depart_compound |
Undocumented |
Method | depart_definition |
Undocumented |
Method | depart_definition_list |
Undocumented |
Method | depart_definition_list_item |
Undocumented |
Method | depart_description |
Undocumented |
Method | depart_docinfo |
Undocumented |
Method | depart_docinfo_item |
Undocumented |
Method | depart_doctest_block |
Undocumented |
Method | depart_entry |
Undocumented |
Method | depart_enumerated_list |
Undocumented |
Method | depart_field |
Undocumented |
Method | depart_field_body |
Undocumented |
Method | depart_field_list |
Undocumented |
Method | depart_field_name |
Undocumented |
Method | depart_footnote |
Undocumented |
Method | depart_footnote_reference |
Undocumented |
Method | depart_image |
Undocumented |
Method | depart_label |
Undocumented |
Method | depart_list_item |
Undocumented |
Method | depart_literal |
Undocumented |
Method | depart_literal_block |
Undocumented |
Method | depart_option_group |
Undocumented |
Method | depart_option_list |
Undocumented |
Method | depart_option_list_item |
Undocumented |
Method | depart_paragraph |
Undocumented |
Method | depart_sidebar |
Undocumented |
Method | depart_subscript |
Undocumented |
Method | depart_subtitle |
Undocumented |
Method | depart_superscript |
Undocumented |
Method | depart_system_message |
Undocumented |
Method | depart_table |
Undocumented |
Method | depart_tbody |
Undocumented |
Method | depart_term |
Undocumented |
Method | depart_thead |
Undocumented |
Method | footnote_backrefs |
Undocumented |
Method | is_compactable |
Undocumented |
Method | section_title_tags |
Undocumented |
Method | set_first_last |
Undocumented |
Method | should_be_compact_paragraph |
Determine if the <p> tags around paragraph node can be omitted. |
Method | visit_address |
Undocumented |
Method | visit_admonition |
Undocumented |
Method | visit_author |
Undocumented |
Method | visit_authors |
Undocumented |
Method | visit_citation |
Undocumented |
Method | visit_citation_reference |
Undocumented |
Method | visit_classifier |
Undocumented |
Method | visit_colspec |
Undocumented |
Method | visit_compound |
Undocumented |
Method | visit_definition |
Undocumented |
Method | visit_definition_list |
Undocumented |
Method | visit_definition_list_item |
Undocumented |
Method | visit_description |
Undocumented |
Method | visit_docinfo |
Undocumented |
Method | visit_docinfo_item |
Undocumented |
Method | visit_doctest_block |
Undocumented |
Method | visit_entry |
Undocumented |
Method | visit_enumerated_list |
The 'start' attribute does not conform to HTML 4.01's strict.dtd, but cannot be emulated in CSS1 (HTML 5 reincludes it). |
Method | visit_field |
Undocumented |
Method | visit_field_body |
Undocumented |
Method | visit_field_list |
Undocumented |
Method | visit_field_name |
Undocumented |
Method | visit_footnote |
Undocumented |
Method | visit_footnote_reference |
Undocumented |
Method | visit_generated |
Undocumented |
Method | visit_image |
Undocumented |
Method | visit_label |
Undocumented |
Method | visit_list_item |
Undocumented |
Method | visit_literal |
Undocumented |
Method | visit_literal_block |
Undocumented |
Method | visit_option_group |
Undocumented |
Method | visit_option_list |
Undocumented |
Method | visit_option_list_item |
Undocumented |
Method | visit_paragraph |
Undocumented |
Method | visit_sidebar |
Undocumented |
Method | visit_subscript |
Undocumented |
Method | visit_subtitle |
Undocumented |
Method | visit_superscript |
Undocumented |
Method | visit_system_message |
Undocumented |
Method | visit_table |
Undocumented |
Method | visit_tbody |
Undocumented |
Method | visit_term |
Undocumented |
Method | visit_thead |
Undocumented |
Class Variable | attribution_formats |
Undocumented |
Class Variable | content_type |
Undocumented |
Class Variable | content_type_mathml |
Undocumented |
Class Variable | doctype |
Undocumented |
Class Variable | object_image_types |
Undocumented |
Class Variable | special_characters |
Character references for characters with a special meaning in HTML. |
Instance Variable | author_in_authors |
Undocumented |
Instance Variable | body |
Undocumented |
Instance Variable | compact_field_list |
Undocumented |
Instance Variable | compact_p |
Undocumented |
Instance Variable | compact_simple |
Undocumented |
Instance Variable | docinfo |
Undocumented |
Instance Variable | in_docinfo |
Undocumented |
Instance Variable | in_document_title |
Undocumented |
Instance Variable | in_sidebar |
Undocumented |
Instance Variable | subtitle |
Undocumented |
Inherited from HTMLTranslator
:
Method | __init__ |
Undocumented |
Method | add_meta |
Undocumented |
Method | astext |
Undocumented |
Method | attval |
Cleanse, HTML encode, and return attribute value text. |
Method | check_simple_list |
Check for a simple list that can be rendered compactly. |
Method | cloak_email |
Try to hide the link text of a email link from harversters. |
Method | cloak_mailto |
Try to hide a mailto: URL from harvesters. |
Method | depart_abbreviation |
Undocumented |
Method | depart_acronym |
Undocumented |
Method | depart_attribution |
Undocumented |
Method | depart_block_quote |
Undocumented |
Method | depart_bullet_list |
Undocumented |
Method | depart_caption |
Undocumented |
Method | depart_contact |
Undocumented |
Method | depart_container |
Undocumented |
Method | depart_copyright |
Undocumented |
Method | depart_date |
Undocumented |
Method | depart_decoration |
Undocumented |
Method | depart_document |
Undocumented |
Method | depart_emphasis |
Undocumented |
Method | depart_figure |
Undocumented |
Method | depart_footer |
Undocumented |
Method | depart_generated |
Undocumented |
Method | depart_header |
Undocumented |
Method | depart_inline |
Undocumented |
Method | depart_legend |
Undocumented |
Method | depart_line |
Undocumented |
Method | depart_line_block |
Undocumented |
Method | depart_math |
Undocumented |
Method | depart_math_block |
Undocumented |
Method | depart_meta |
Undocumented |
Method | depart_option |
Undocumented |
Method | depart_option_argument |
Undocumented |
Method | depart_option_string |
Undocumented |
Method | depart_organization |
Undocumented |
Method | depart_problematic |
Undocumented |
Method | depart_reference |
Undocumented |
Method | depart_revision |
Undocumented |
Method | depart_row |
Undocumented |
Method | depart_rubric |
Undocumented |
Method | depart_section |
Undocumented |
Method | depart_status |
Undocumented |
Method | depart_strong |
Undocumented |
Method | depart_target |
Undocumented |
Method | depart_Text |
Undocumented |
Method | depart_tgroup |
Undocumented |
Method | depart_title |
Undocumented |
Method | depart_title_reference |
Undocumented |
Method | depart_topic |
Undocumented |
Method | depart_transition |
Undocumented |
Method | depart_version |
Undocumented |
Method | emptytag |
Construct and return an XML-compatible empty tag. |
Method | encode |
Encode special characters in text & return. |
Method | set_class_on_child |
Set class class_ on the visible child no. index of node . Do nothing if node has fewer children than index . |
Method | starttag |
Construct and return a start tag given a node (id & class attributes are extracted), tag name, and optional attributes. |
Method | stylesheet_call |
Return code to reference or embed stylesheet file path |
Method | unimplemented_visit |
Undocumented |
Method | visit_abbreviation |
Undocumented |
Method | visit_acronym |
Undocumented |
Method | visit_attribution |
Undocumented |
Method | visit_block_quote |
Undocumented |
Method | visit_bullet_list |
Undocumented |
Method | visit_caption |
Undocumented |
Method | visit_comment |
Escape double-dashes in comment text. |
Method | visit_contact |
Undocumented |
Method | visit_container |
Undocumented |
Method | visit_copyright |
Undocumented |
Method | visit_date |
Undocumented |
Method | visit_decoration |
Undocumented |
Method | visit_document |
Undocumented |
Method | visit_emphasis |
Undocumented |
Method | visit_figure |
Undocumented |
Method | visit_footer |
Undocumented |
Method | visit_header |
Undocumented |
Method | visit_inline |
Undocumented |
Method | visit_legend |
Undocumented |
Method | visit_line |
Undocumented |
Method | visit_line_block |
Undocumented |
Method | visit_math |
Undocumented |
Method | visit_math_block |
Undocumented |
Method | visit_meta |
Undocumented |
Method | visit_option |
Undocumented |
Method | visit_option_argument |
Undocumented |
Method | visit_option_string |
Undocumented |
Method | visit_organization |
Undocumented |
Method | visit_problematic |
Undocumented |
Method | visit_raw |
Undocumented |
Method | visit_reference |
Undocumented |
Method | visit_revision |
Undocumented |
Method | visit_row |
Undocumented |
Method | visit_rubric |
Undocumented |
Method | visit_section |
Undocumented |
Method | visit_status |
Undocumented |
Method | visit_strong |
Undocumented |
Method | visit_substitution_definition |
Internal only. |
Method | visit_substitution_reference |
Undocumented |
Method | visit_target |
Undocumented |
Method | visit_Text |
Undocumented |
Method | visit_tgroup |
Undocumented |
Method | visit_title |
Undocumented |
Method | visit_title_reference |
Undocumented |
Method | visit_topic |
Undocumented |
Method | visit_transition |
Undocumented |
Method | visit_version |
Undocumented |
Class Variable | embedded_stylesheet |
Undocumented |
Class Variable | generator |
Undocumented |
Class Variable | head_prefix_template |
Undocumented |
Class Variable | in_word_wrap_point |
Undocumented |
Class Variable | lang_attribute |
Undocumented |
Class Variable | math_tags |
Undocumented |
Class Variable | mathjax_script |
Undocumented |
Class Variable | stylesheet_link |
Undocumented |
Class Variable | words_and_spaces |
Undocumented |
Class Variable | xml_declaration |
Undocumented |
Instance Variable | body_pre_docinfo |
Undocumented |
Instance Variable | body_prefix |
Undocumented |
Instance Variable | body_suffix |
Undocumented |
Instance Variable | colspecs |
Undocumented |
Instance Variable | context |
Heterogeneous stack. |
Instance Variable | footer |
Undocumented |
Instance Variable | fragment |
Undocumented |
Instance Variable | head |
Undocumented |
Instance Variable | head_prefix |
Undocumented |
Instance Variable | header |
Undocumented |
Instance Variable | html_body |
Undocumented |
Instance Variable | html_head |
Undocumented |
Instance Variable | html_prolog |
Undocumented |
Instance Variable | html_subtitle |
Undocumented |
Instance Variable | html_title |
Undocumented |
Instance Variable | image_loading |
Undocumented |
Instance Variable | in_mailto |
Undocumented |
Instance Variable | initial_header_level |
Undocumented |
Instance Variable | language |
Undocumented |
Instance Variable | math_header |
Undocumented |
Instance Variable | math_output |
Undocumented |
Instance Variable | math_output_options |
Undocumented |
Instance Variable | mathjax_url |
URL of the MathJax javascript library. |
Instance Variable | meta |
Undocumented |
Instance Variable | section_level |
Undocumented |
Instance Variable | settings |
Undocumented |
Instance Variable | stylesheet |
Undocumented |
Instance Variable | title |
Undocumented |
Inherited from NodeVisitor
(via HTMLTranslator
):
Method | dispatch_departure |
Call self."depart_ + node class name" with node as parameter. If the depart_... method does not exist, call self.unknown_departure. |
Method | dispatch_visit |
Call self."visit_ + node class name" with node as parameter. If the visit_... method does not exist, call self.unknown_visit. |
Method | unknown_departure |
Called before exiting unknown Node types. |
Method | unknown_visit |
Called when entering unknown Node types. |
Class Variable | optional |
Tuple containing node class names (as strings). |
Instance Variable | document |
Undocumented |
docutils.writers.pep_html.HTMLTranslator
Undocumented
docutils.writers.s5_html.S5HTMLTranslator
Undocumented