module documentation
(source)

Docutils document tree element class library.

Classes in CamelCase are abstract base classes or auxiliary classes. The one exception is Text, for a text (PCDATA) node; uppercase is used to differentiate from element classes. Classes in lower_case_with_underscores are element classes, matching the XML element generic identifiers in the DTD.

The position of each node (the level at which it can occur) is significant and is represented by abstract base classes (Root, Structural, Body, Inline, etc.). Certain transformations will be easier because we can use isinstance(node, base_class) to determine the position of the node in the hierarchy.

Class abbreviation Undocumented
Class acronym Undocumented
Class address Undocumented
Class ​Admonition Undocumented
Class admonition Undocumented
Class attention Undocumented
Class attribution Undocumented
Class author Undocumented
Class authors Undocumented
Class ​Back​Linkable Undocumented
Class ​Bibliographic Undocumented
Class block​_quote Undocumented
Class ​Body Undocumented
Class bullet​_list Undocumented
Class caption Undocumented
Class caution Undocumented
Class citation Undocumented
Class citation​_reference Undocumented
Class classifier Undocumented
Class colspec Undocumented
Class comment Undocumented
Class compound Undocumented
Class contact Undocumented
Class container Undocumented
Class copyright Undocumented
Class danger Undocumented
Class date Undocumented
Class decoration Undocumented
Class ​Decorative Undocumented
Class definition Undocumented
Class definition​_list Undocumented
Class definition​_list​_item Undocumented
Class description Undocumented
Class docinfo Undocumented
Class doctest​_block Undocumented
Class document The document root element.
Class ​Element Element is the superclass to all specific elements.
Class emphasis Undocumented
Class entry Undocumented
Class enumerated​_list Undocumented
Class error Undocumented
Class field Undocumented
Class field​_body Undocumented
Class field​_list Undocumented
Class field​_name Undocumented
Class figure Undocumented
Class ​Fixed​Text​Element An element which directly contains preformatted text.
Class footer Undocumented
Class footnote Undocumented
Class footnote​_reference Undocumented
Class ​General Undocumented
Class generated Undocumented
Class ​Generic​Node​Visitor Generic "Visitor" abstract superclass, for simple traversals.
Class header Undocumented
Class hint Undocumented
Class image Undocumented
Class important Undocumented
Class ​Inline Undocumented
Class inline Undocumented
Class ​Invisible Internal elements that don't appear in output.
Class label Undocumented
Class ​Labeled Contains a label as its first element.
Class legend Undocumented
Class line Undocumented
Class line​_block Undocumented
Class list​_item Undocumented
Class literal Undocumented
Class literal​_block Undocumented
Class math Undocumented
Class math​_block Undocumented
Class ​Node Abstract base class of nodes in a document tree.
Class ​Node​Found Raise to indicate that the target of a search has been found. This exception must be caught by the client; it is not caught by the traversal code.
Class ​Node​Visitor "Visitor" pattern [GoF95]_ abstract superclass implementation for document tree traversals.
Class note Undocumented
Class option Undocumented
Class option​_argument Undocumented
Class option​_group Undocumented
Class option​_list Undocumented
Class option​_list​_item Undocumented
Class option​_string Undocumented
Class organization Undocumented
Class paragraph Undocumented
Class ​Part Undocumented
Class pending No summary
Class ​Pre​Bibliographic Category of Node which may occur before Bibliographic Nodes.
Class problematic Undocumented
Class raw Raw data that is to be passed untouched to the Writer.
Class reference Undocumented
Class ​Referential Undocumented
Class reprunicode A unicode sub-class that removes the initial u from unicode's repr.
Class ​Resolvable Undocumented
Class revision Undocumented
Class ​Root Undocumented
Class row Undocumented
Class rubric Undocumented
Class section Undocumented
Class ​Sequential List-like elements.
Class sidebar No summary
Class ​Skip​Children Do not visit any children of the current node. The current node's siblings and depart_... method are not affected.
Class ​Skip​Departure Do not call the current node's depart_... method. The current node's children and siblings are not affected.
Class ​Skip​Node Do not visit the current node's children, and do not call the current node's depart_... method.
Class ​Skip​Siblings Do not visit any more siblings (to the right) of the current node. The current node's children and its depart_... method are not affected.
Class ​Sparse​Node​Visitor No summary
Class ​Special Special internal body elements.
Class status Undocumented
Class ​Stop​Traversal No summary
Class strong Undocumented
Class ​Structural Undocumented
Class subscript Undocumented
Class substitution​_definition Undocumented
Class substitution​_reference Undocumented
Class subtitle Undocumented
Class superscript Undocumented
Class system​_message System message element.
Class table Undocumented
Class target Undocumented
Class ​Targetable No class docstring; 1/2 class variable documented
Class tbody Undocumented
Class term Undocumented
Class ​Text Instances are terminal nodes (leaves) containing text only; no child nodes or attributes. Initialize by passing a string to the constructor. Access the text itself with the astext method.
Class ​Text​Element An element which directly contains text.
Class tgroup Undocumented
Class thead Undocumented
Class tip Undocumented
Class title Undocumented
Class title​_reference Undocumented
Class ​Titular Undocumented
Class topic Topics are terminal, "leaf" mini-sections, like block quotes with titles, or textual figures. A topic is just like a section, except that it has no subsections, and it doesn't have to conform to section placement rules.
Class transition Undocumented
Class ​Tree​Copy​Visitor Make a complete copy of a tree or branch, including element attributes.
Class ​Tree​Pruning​Exception Base class for NodeVisitor-related tree pruning exceptions.
Class version Undocumented
Class warning Undocumented
Function dupname Undocumented
Function ensure​_str Failsave conversion of unicode to str.
Function fully​_normalize​_name Return a case- and whitespace-normalized name.
Function make​_id Convert string into an identifier and return it.
Function pseudo​_quoteattr Quote attributes for pseudo-xml
Function serial​_escape Escape string values that are elements of a list, for serialization.
Function unescape Return a string with nulls removed or restored to backslashes. Backslash-escaped spaces are also removed.
Function whitespace​_normalize​_name Return a whitespace-normalized name.
Variable node​_class​_names A list of names of all concrete Node subclasses.
Class _traversal​_list Undocumented
Function _add​_node​_class​_names Save typing with dynamic assignments:
Function _call​_default​_departure Undocumented
Function _call​_default​_visit Undocumented
Function _nop Undocumented
Variable _non​_id​_at​_ends Undocumented
Variable _non​_id​_chars Undocumented
Variable _non​_id​_translate Undocumented
Variable _non​_id​_translate​_digraphs Undocumented
def dupname(node, name): (source)

Undocumented

def ensure_str(s): (source)
Failsave conversion of unicode to str.
def fully_normalize_name(name): (source)
Return a case- and whitespace-normalized name.
def make_id(string): (source)

Convert string into an identifier and return it.

Docutils identifiers will conform to the regular expression [a-z](-?[a-z0-9]+)*. For CSS compatibility, identifiers (the "class" and "id" attributes) should have no underscores, colons, or periods. Hyphens may be used.

  • The HTML 4.01 spec defines identifiers based on SGML tokens:

    ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

  • However the CSS1 spec defines identifiers based on the "name" token, a tighter interpretation ("flex" tokenizer notation; "latin1" and "escape" 8-bit characters have been replaced with entities):

    unicode     \[0-9a-f]{1,4}
    latin1      [¡-ÿ]
    escape      {unicode}|\[ -~¡-ÿ]
    nmchar      [-a-z0-9]|{latin1}|{escape}
    name        {nmchar}+
    

The CSS1 "nmchar" rule does not include underscores ("_"), colons (":"), or periods ("."), therefore "class" and "id" attributes should not contain these characters. They should be replaced with hyphens ("-"). Combined with HTML's requirements (the first character must be a letter; no "unicode", "latin1", or "escape" characters), this results in the [a-z](-?[a-z0-9]+)* pattern.

def pseudo_quoteattr(value): (source)
Quote attributes for pseudo-xml
def serial_escape(value): (source)
Escape string values that are elements of a list, for serialization.
def unescape(text, restore_backslashes=False, respect_whitespace=False): (source)
Return a string with nulls removed or restored to backslashes. Backslash-escaped spaces are also removed.
def whitespace_normalize_name(name): (source)
Return a whitespace-normalized name.
node_class_names = (source)
A list of names of all concrete Node subclasses.
def _add_node_class_names(names): (source)
Save typing with dynamic assignments:
def _call_default_departure(self, node): (source)

Undocumented

def _call_default_visit(self, node): (source)

Undocumented

def _nop(self, node): (source)

Undocumented

_non_id_at_ends = (source)

Undocumented

_non_id_chars = (source)

Undocumented

_non_id_translate: dict[int, str] = (source)

Undocumented

_non_id_translate_digraphs: dict[int, str] = (source)

Undocumented