class HTMLTranslator(nodes.NodeVisitor): (source)
Known subclasses: docutils.writers.html4css1.HTMLTranslator
, docutils.writers.html5_polyglot.HTMLTranslator
Generic Docutils to HTML translator.
See the
html4css1
andhtml5_polyglot
writers for full featured HTML writers.Important
The
visit_*
anddepart_*
methods use a heterogeneous stack,self.context
. When subclassing, make sure to be consistent in its use!Examples for robust coding:
Override both
visit_*
anddepart_*
methods, don't call the parent functions.Extend both and unconditionally call the parent functions:
def visit_example(self, node): if foo: self.body.append('<div class="foo">') html4css1.HTMLTranslator.visit_example(self, node) def depart_example(self, node): html4css1.HTMLTranslator.depart_example(self, node) if foo: self.body.append('</div>')Extend both, calling the parent functions under the same conditions:
def visit_example(self, node): if foo: self.body.append('<div class="foo">
- else: # call the parent method
- _html_base.HTMLTranslator.visit_example(self, node)
- else: # call the parent method
- _html_base.HTMLTranslator.depart_example(self, node)
Extend one method (call the parent), but don't otherwise use the
self.context
stack:
def depart_example(self, node): _html_base.HTMLTranslator.depart_example(self, node) if foo: # implementation-specific code # that does not use `self.context` self.body.append('</div>
')
This way, changes in stack use will not bite you.
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_address |
Undocumented |
Method | depart_admonition |
Undocumented |
Method | depart_attribution |
Undocumented |
Method | depart_author |
Undocumented |
Method | depart_authors |
Undocumented |
Method | depart_block_quote |
Undocumented |
Method | depart_bullet_list |
Undocumented |
Method | depart_caption |
Undocumented |
Method | depart_citation |
Undocumented |
Method | depart_citation_reference |
Undocumented |
Method | depart_classifier |
Undocumented |
Method | depart_colspec |
Undocumented |
Method | depart_compound |
Undocumented |
Method | depart_contact |
Undocumented |
Method | depart_container |
Undocumented |
Method | depart_copyright |
Undocumented |
Method | depart_date |
Undocumented |
Method | depart_decoration |
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_document |
Undocumented |
Method | depart_emphasis |
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_figure |
Undocumented |
Method | depart_footer |
Undocumented |
Method | depart_footnote |
Undocumented |
Method | depart_footnote_reference |
Undocumented |
Method | depart_generated |
Undocumented |
Method | depart_header |
Undocumented |
Method | depart_image |
Undocumented |
Method | depart_inline |
Undocumented |
Method | depart_label |
Undocumented |
Method | depart_legend |
Undocumented |
Method | depart_line |
Undocumented |
Method | depart_line_block |
Undocumented |
Method | depart_list_item |
Undocumented |
Method | depart_literal |
Undocumented |
Method | depart_literal_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_group |
Undocumented |
Method | depart_option_list |
Undocumented |
Method | depart_option_list_item |
Undocumented |
Method | depart_option_string |
Undocumented |
Method | depart_organization |
Undocumented |
Method | depart_paragraph |
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_sidebar |
Undocumented |
Method | depart_status |
Undocumented |
Method | depart_strong |
Undocumented |
Method | depart_subscript |
Undocumented |
Method | depart_subtitle |
Undocumented |
Method | depart_superscript |
Undocumented |
Method | depart_system_message |
Undocumented |
Method | depart_table |
Undocumented |
Method | depart_target |
Undocumented |
Method | depart_tbody |
Undocumented |
Method | depart_term |
Leave the end tag to self.visit_definition() , in case there's a classifier. |
Method | depart_Text |
Undocumented |
Method | depart_tgroup |
Undocumented |
Method | depart_thead |
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 | is_compactable |
Undocumented |
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_address |
Undocumented |
Method | visit_admonition |
Undocumented |
Method | visit_attribution |
Undocumented |
Method | visit_author |
Undocumented |
Method | visit_authors |
Undocumented |
Method | visit_block_quote |
Undocumented |
Method | visit_bullet_list |
Undocumented |
Method | visit_caption |
Undocumented |
Method | visit_citation |
Undocumented |
Method | visit_citation_reference |
Undocumented |
Method | visit_classifier |
Undocumented |
Method | visit_colspec |
Undocumented |
Method | visit_comment |
Escape double-dashes in comment text. |
Method | visit_compound |
Undocumented |
Method | visit_contact |
Undocumented |
Method | visit_container |
Undocumented |
Method | visit_copyright |
Undocumented |
Method | visit_date |
Undocumented |
Method | visit_decoration |
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_document |
Undocumented |
Method | visit_emphasis |
Undocumented |
Method | visit_entry |
Undocumented |
Method | visit_enumerated_list |
Undocumented |
Method | visit_field |
Undocumented |
Method | visit_field_body |
Undocumented |
Method | visit_field_list |
Undocumented |
Method | visit_field_name |
Undocumented |
Method | visit_figure |
Undocumented |
Method | visit_footer |
Undocumented |
Method | visit_footnote |
Undocumented |
Method | visit_footnote_reference |
Undocumented |
Method | visit_generated |
Undocumented |
Method | visit_header |
Undocumented |
Method | visit_image |
Undocumented |
Method | visit_inline |
Undocumented |
Method | visit_label |
Undocumented |
Method | visit_legend |
Undocumented |
Method | visit_line |
Undocumented |
Method | visit_line_block |
Undocumented |
Method | visit_list_item |
Undocumented |
Method | visit_literal |
Undocumented |
Method | visit_literal_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_group |
Undocumented |
Method | visit_option_list |
Undocumented |
Method | visit_option_list_item |
Undocumented |
Method | visit_option_string |
Undocumented |
Method | visit_organization |
Undocumented |
Method | visit_paragraph |
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_sidebar |
Undocumented |
Method | visit_status |
Undocumented |
Method | visit_strong |
Undocumented |
Method | visit_subscript |
Undocumented |
Method | visit_substitution_definition |
Internal only. |
Method | visit_substitution_reference |
Undocumented |
Method | visit_subtitle |
Undocumented |
Method | visit_superscript |
Undocumented |
Method | visit_system_message |
Undocumented |
Method | visit_table |
Undocumented |
Method | visit_target |
Undocumented |
Method | visit_tbody |
Undocumented |
Method | visit_term |
Undocumented |
Method | visit_Text |
Undocumented |
Method | visit_tgroup |
Undocumented |
Method | visit_thead |
Undocumented |
Method | visit_title |
Only 6 section levels are supported by HTML. |
Method | visit_title_reference |
Undocumented |
Method | visit_topic |
Undocumented |
Method | visit_transition |
Undocumented |
Method | visit_version |
Undocumented |
Class Variable | attribution_formats |
Undocumented |
Class Variable | content_type |
Undocumented |
Class Variable | doctype |
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 | special_characters |
Character references for characters with a special meaning in HTML. |
Class Variable | stylesheet_link |
Undocumented |
Class Variable | words_and_spaces |
Undocumented |
Class Variable | xml_declaration |
Undocumented |
Instance Variable | author_in_authors |
Undocumented |
Instance Variable | body |
Undocumented |
Instance Variable | body_pre_docinfo |
Undocumented |
Instance Variable | body_prefix |
Undocumented |
Instance Variable | body_suffix |
Undocumented |
Instance Variable | colspecs |
Undocumented |
Instance Variable | compact_field_list |
Undocumented |
Instance Variable | compact_p |
Undocumented |
Instance Variable | compact_simple |
Undocumented |
Instance Variable | context |
Heterogeneous stack. |
Instance Variable | docinfo |
Undocumented |
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 | in_docinfo |
Undocumented |
Instance Variable | in_document_title |
Undocumented |
Instance Variable | in_footnote_list |
Undocumented |
Instance Variable | in_mailto |
Undocumented |
Instance Variable | in_sidebar |
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 | subtitle |
Undocumented |
Instance Variable | title |
Undocumented |
Instance Variable | topic_classes |
Undocumented |
Inherited from NodeVisitor
:
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.nodes.NodeVisitor.__init__
docutils.writers.s5_html.S5HTMLTranslator
Undocumented
docutils.writers.html4css1.HTMLTranslator
, docutils.writers.html5_polyglot.HTMLTranslator
Undocumented
docutils.writers.html5_polyglot.HTMLTranslator
, docutils.writers.s5_html.S5HTMLTranslator
Undocumented
docutils.writers.html5_polyglot.HTMLTranslator
, docutils.writers.s5_html.S5HTMLTranslator
Undocumented
docutils.writers.html5_polyglot.HTMLTranslator
, docutils.writers.s5_html.S5HTMLTranslator
Undocumented
docutils.writers.html4css1.HTMLTranslator
, docutils.writers.html5_polyglot.HTMLTranslator
Undocumented
class_
on the visible child no. index of node
.
Do nothing if node has fewer children than index
.docutils.writers.html4css1.HTMLTranslator
, docutils.writers.html5_polyglot.HTMLTranslator
Undocumented
docutils.writers.html4css1.HTMLTranslator
, docutils.writers.html5_polyglot.HTMLTranslator
Undocumented
docutils.writers.html4css1.HTMLTranslator
, docutils.writers.html5_polyglot.HTMLTranslator
Undocumented
docutils.writers.html5_polyglot.HTMLTranslator
, docutils.writers.s5_html.S5HTMLTranslator
Undocumented
docutils.writers.html4css1.HTMLTranslator
, docutils.writers.html5_polyglot.HTMLTranslator
Undocumented
docutils.writers.s5_html.S5HTMLTranslator
docutils.writers.html4css1.HTMLTranslator
Heterogeneous stack.
Used by visit_* and depart_* functions in conjunction with the tree traversal. Make sure that the pops correspond to the pushes.
docutils.writers.html4css1.HTMLTranslator
, docutils.writers.html5_polyglot.HTMLTranslator
Undocumented
URL of the MathJax javascript library.
The MathJax library ought to be installed on the same
server as the rest of the deployed site files and specified
in the math-output
setting appended to "mathjax".
See Docutils Configuration.
The fallback tries a local MathJax installation at /usr/share/javascript/mathjax/MathJax.js.