Docutils文档树

Docutils DTD指南

作者

David Goodger

联系

docutils-develop@lists.sourceforge.net

Revision

$Revision: 7882 $

Date

$Date: 2015-04-20 12:55:19 +0200 (Mo, 20. Apr 2015) $

Copyright

本文档已置于公共领域。

This document describes the XML data structure of Docutils documents: the relationships and semantics of elements and attributes. The Docutils document structure is formally defined by the Docutils Generic DTD XML document type definition, docutils.dtd, which is the definitive source for details of element structural relationships.

This document does not discuss implementation details. Those can be found in internal documentation (docstrings) for the docutils.nodes module, where the document tree data structure is implemented in a class library.

The reader is assumed to have some familiarity with XML or SGML, and an understanding of the data structure meaning of “tree”. For a list of introductory articles, see Introducing the Extensible Markup Language (XML).

The reStructuredText markup is used for illustrative examples throughout this document. For a gentle introduction, see A ReStructuredText Primer. For complete technical details, see the reStructuredText Markup Specification.

元素层次结构

Below is a simplified diagram of the hierarchy of elements in the Docutils document tree structure. An element may contain any other elements immediately below it in the diagram. Notes are written in square brackets. Element types in parentheses indicate recursive or one-to-many relationships; sections may contain (sub)sections, tables contain further body elements, etc.

+--------------------------------------------------------------------+
| document  [may begin with a title, subtitle, decoration, docinfo]  |
|                             +--------------------------------------+
|                             | sections  [each begins with a title] |
+-----------------------------+-------------------------+------------+
| [body elements:]                                      | (sections) |
|         | - literal | - lists  |       | - hyperlink  +------------+
|         |   blocks  | - tables |       |   targets    |
| para-   | - doctest | - block  | foot- | - sub. defs  |
| graphs  |   blocks  |   quotes | notes | - comments   |
+---------+-----------+----------+-------+--------------+
| [text]+ | [text]    | (body elements)  | [text]       |
| (inline +-----------+------------------+--------------+
| markup) |
+---------+

The Docutils document model uses a simple, recursive model for section structure. A document node may contain body elements and section elements. Sections in turn may contain body elements and sections. The level (depth) of a section element is determined from its physical nesting level; unlike other document models (<h1> in HTML, <sect1> in DocBook, <div1> in XMLSpec) the level is not incorporated into the element name.

The Docutils document model uses strict element content models. Every element has a unique structure and semantics, but elements may be classified into general categories (below). Only elements which are meant to directly contain text data have a mixed content model, where text data and inline elements may be intermixed. This is unlike the much looser HTML document model, where paragraphs and text data may occur at the same level.

结构要素

Structural elements may only contain child elements; they do not directly contain text data. Structural elements may contain body elements or further structural elements. Structural elements can only be child elements of other structural elements.

Category members: document, section, topic, sidebar

结构子弹

Structural subelements are child elements of structural elements. Simple structuctural subelements (title, subtitle) contain text data; the others are compound and do not directly contain text data.

类别成员: title, subtitle, decoration, docinfo, transition

Bibliographic Elements

The docinfo element is an optional child of document. It groups bibliographic elements together. All bibliographic elements except authors and field contain text data. authors contains further bibliographic elements (most notably author). field contains field_name and field_body body subelements.

Category members: address, author, authors, contact, copyright, date, field, organization, revision, status, version

装饰元素

The decoration element is also an optional child of document. It groups together elements used to generate page headers and footers.

类别成员: footer, header

主体元素

Body elements are contained within structural elements and compound body elements. There are two subcategories of body elements: simple and compound.

Category members: admonition, attention, block_quote, bullet_list, caution, citation, comment, compound, container, danger, definition_list, doctest_block, enumerated_list, error, field_list, figure, footnote, hint, image, important, line_block, literal_block, note, option_list, paragraph, pending, raw, rubric, substitution_definition, system_message, table, target, tip, warning

简体元素

Simple body elements are empty or directly contain text data. Those that contain text data may also contain inline elements. Such elements therefore have a “mixed content model”.

Category members: comment, doctest_block, image, literal_block, math_block, paragraph, pending, raw, rubric, substitution_definition, target

复合体元素

Compound body elements contain local substructure (body subelements) and further body elements. They do not directly contain text data.

Category members: admonition, attention, block_quote, bullet_list, caution, citation, compound, container, danger, definition_list, enumerated_list, error, field_list, figure, footnote, hint, important, line_block, note, option_list, system_message, table, tip, warning

主体子元素

Compound body elements contain specific subelements (e.g. bullet_list contains list_item). Subelements may themselves be compound elements (containing further child elements, like field) or simple data elements (containing text data, like field_name). These subelements always occur within specific parent elements, never at the body element level (beside paragraphs, etc.).

Category members (simple): attribution, caption, classifier, colspec, field_name, label, line, option_argument, option_string, term

Category members (compound): definition, definition_list_item, description, entry, field, field_body, legend, list_item, option, option_group, option_list_item, row, tbody, tgroup, thead

内联元素

Inline elements directly contain text data, and may also contain further inline elements. Inline elements are contained within simple body elements. Most inline elements have a “mixed content model”.

Category members: abbreviation, acronym, citation_reference, emphasis, footnote_reference, generated, image, inline, literal, math, problematic, reference, strong, subscript, substitution_reference, superscript, target, title_reference, raw

元素参考

Each element in the DTD (document type definition) is described in its own section below. Each section contains an introduction plus the following subsections:

  • 细节(元素关系和语义):

    • Category: One or more references to the element categories in Element Hierarchy above. Some elements belong to more than one category.

    • 父母:可能包含元素的元素列表。

    • 子元素:元素中可能出现的元素列表。

    • Analogues: Describes analogous elements in well-known document models such as HTML or DocBook. Lists similarities and differences.

    • 处理:列出元素的格式或呈现建议。

  • Content Model:

    来自 Docutils DTD 的正式XML内容模型,接着是:

    • Attributes: Describes (or refers to descriptions of) the possible values and semantics of each attribute.

    • Parameter Entities: Lists the parameter entities which directly or indirectly include the element.

  • Examples: reStructuredText examples are shown along with fragments of the document trees resulting from parsing. Pseudo-XML is used for the results of parsing and processing. Pseudo-XML is a representation of XML where nesting is indicated by indentation and end-tags are not shown. Some of the precision of real XML is given up in exchange for easier readability. For example, the following are equivalent:

    • 实XML:

      <document>
      <section ids="a-title" names="a title">
      <title>A Title</title>
      <paragraph>A paragraph.</paragraph>
      </section>
      </document>
      
    • 伪XML:

      <document>
          <section ids="a-title" names="a title">
              <title>
                  A Title
              <paragraph>
                  A paragraph.
      

Many of the element reference sections below are marked “to be completed”. Please help complete this document by contributing to its writing.

缩写

The abbreviation element is an inline element used to represent an abbreviation being used in the document. An example of an abbreviation is ‘St’ being used instead of ‘Street’.

细节
类别

Inline Elements

父母

All elements employing the %inline.elements; parameter entities in their content models may contain abbreviation.

孩子

abbreviation elements may contain text data plus inline elements.

类似物

abbreviation is analogous to the HTML “abbr” element.

内容模型
%text.model;
属性

The abbreviation element contains only the common attributes: ids, names, dupnames, source, and classes.

例子

The abbreviation element is not exposed in default restructured text. It can only be accessed through custom roles.

Pseudo-XML 来自自定义的 :abbr: role 示例:

<paragraph>
    <abbreviation explanation="Street">
        St
    is a common abbreviation for "street".

address

The address element holds the surface mailing address information for the author (individual or group) of the document, or a third-party contact address. Its structure is identical to that of the literal_block element: whitespace is significant, especially newlines.

细节
类别

Bibliographic Elements

父母

以下元素可能包含 address: docinfo, authors

孩子

address elements contain text data plus inline elements.

类似物

address 类似于DocBook “address” 元素。

处理

As with the literal_block element, newlines and other whitespace is significant and must be preserved. However, a monospaced typeface need not be used.

也可以看看 docinfo.

内容模型
%text.model;
属性

The address element contains the common attributes (ids, names, dupnames, source, and classes), plus xml:space.

参数实体

The %bibliographic.elements; parameter entity directly includes address.

例子

reStructuredText 资源:

Document Title
==============

:Address: 123 Example Ave.
          Example, EX

解析并应用转换后完成 pseudo-XML 结果:

<document ids="document-title" names="document title">
    <title>
        Document Title
    <docinfo>
        <address>
            123 Example Ave.
            Example, EX

有关更完整的示例,请参阅 docinfo ,包括处理上下文。

admonition

This element is a generic, titled admonition. Also see the specific admonition elements Docutils offers (in alphabetical order): caution, danger, error, hint, important, note, tip, warning.

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain admonition.

孩子

admonition elements begin with a title and may contain one or more body elements.

类似物

admonition has no direct analogues in common DTDs. It can be emulated with primitives and type effects.

处理

清晰呈现(插入和/或在框中等)。

内容模型
(title, (%body.elements;)+)
属性

The admonition element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %body.elements; parameter entity directly includes admonition. The %structure.model; parameter entity indirectly includes admonition.

例子

reStructuredText 资源:

.. admonition:: And, by the way...

   You can make up your own admonition too.

Pseudo-XML 简单解析的片段:

<admonition class="admonition-and-by-the-way">
    <title>
        And, by the way...
    <paragraph>
        You can make up your own admonition too.

attention

The attention element is an admonition, a distinctive and self-contained notice. Also see the other admonition elements Docutils offers (in alphabetical order): caution, danger, error, hint, important, note, tip, warning, and the generic admonition.

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain attention.

孩子

attention elements contain one or more body elements.

类似物

attention has no direct analogues in common DTDs. It can be emulated with primitives and type effects.

处理

Rendered distinctly (inset and/or in a box, etc.), with the generated title “Attention!” (or similar).

内容模型
(%body.elements;)+
属性

The attention element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %body.elements; parameter entity directly includes attention. The %structure.model; parameter entity indirectly includes attention.

例子

reStructuredText 资源:

.. Attention:: All your base are belong to us.

Pseudo-XML 简单解析的片段:

<attention>
    <paragraph>
        All your base are belong to us.

author

author 元素保存文档作者的姓名。

细节
类别

Bibliographic Elements

父母

以下元素可能包含 author: docinfo, authors

孩子

author 元素可能包含文本数据和 inline elements

类似物

author 类似于DocBook “author” 元素。

处理

查看 docinfo.

内容模型
%text.model;
属性

The author element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %bibliographic.elements; parameter entity directly includes author.

例子

reStructuredText 资源:

Document Title
==============

:Author: J. Random Hacker

解析并应用转换后完成 pseudo-XML 结果:

<document ids="document-title" names="document title">
    <title>
        Document Title
    <docinfo>
        <author>
            J. Random Hacker

有关更完整的示例,请参阅 docinfo ,包括处理上下文。

authors

The authors element is a container for author information for documents with multiple authors.

细节
类别

Bibliographic Elements

父母

只有 docinfo 元素包含 authors

孩子

authors elements may contain the following elements: author, organization, address, contact

类似物

authors is analogous to the DocBook “authors” element.

处理

查看 docinfo.

内容模型
((author, organization?, address?, contact?)+)
属性

The authors element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %bibliographic.elements; parameter entity directly includes authors.

例子

reStructuredText 资源:

Document Title
==============

:Authors: J. Random Hacker; Jane Doe

解析并应用转换后完成 pseudo-XML 结果:

<document ids="document-title" names="document title">
    <title>
        Document Title
    <docinfo>
        <authors>
            <author>
                J. Random Hacker
            <author>
                Jane Doe

In reStructuredText, multiple author’s names are separated with semicolons (“;”) or commas (“,”); semicolons take precedence. There is currently no way to represent the author’s organization, address, or contact in a reStructuredText “Authors” field.

有关更完整的示例,请参阅 docinfo ,包括处理上下文。

block_quote

The block_quote element is used for quotations set off from the main text (standalone).

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain block_quote.

孩子

block_quote elements contain body elements followed by an optional attribution element.

类似物

block_quote is analogous to the “blockquote” element in both HTML and DocBook.

处理

block_quote elements serve to set their contents off from the main text, typically with indentation and/or other decoration.

内容模型
((%body.elements;)+, attribution?)
属性

The block_quote element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %body.elements; parameter entity directly includes block_quote. The %structure.model; parameter entity indirectly includes block_quote.

例子

reStructuredText 资源:

As a great paleontologist once said,

    This theory, that is mine, is mine.

    -- Anne Elk (Miss)

Pseudo-XML 简单解析的片段:

<paragraph>
    As a great paleontologist once said,
<block_quote>
    <paragraph>
        This theory, that is mine, is mine.
    <attribution>
        Anne Elk (Miss)

bullet_list

The bullet_list element contains list_item elements which are uniformly marked with bullets. Bullets are typically simple dingbats (symbols) such as circles and squares.

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain bullet_list.

孩子

bullet_list elements contain one or more list_item elements.

类似物

bullet_list is analogous to the HTML “ul” element and to the DocBook “itemizedlist” element. HTML’s “ul” is short for “unordered list”, which we consider to be a misnomer. “Unordered” implies that the list items may be randomly rearranged without affecting the meaning of the list. Bullet lists are often ordered; the ordering is simply left implicit.

处理

Each list item should begin a new vertical block, prefaced by a bullet/dingbat.

内容模型
(list_item +)
属性

The bullet_list element contains the common attributes (ids, names, dupnames, source, and classes), plus bullet.

bullet is used to record the style of bullet from the input data. In documents processed from reStructuredText, it contains one of “-“, “+”, or “*”. It may be ignored in processing.

参数实体

The %body.elements; parameter entity directly includes bullet_list. The %structure.model; parameter entity indirectly includes bullet_list.

例子

reStructuredText 资源:

- Item 1, paragraph 1.

  Item 1, paragraph 2.

- Item 2.

Pseudo-XML 简单解析的片段:

<bullet_list bullet="-">
    <list_item>
        <paragraph>
            Item 1, paragraph 1.
        <paragraph>
            Item 1, paragraph 2.
    <list_item>
        <paragraph>
            Item 2.

See list_item for another example.

caution

The caution element is an admonition, a distinctive and self-contained notice. Also see the other admonition elements Docutils offers (in alphabetical order): attention, danger, error, hint, important, note, tip, warning, and the generic admonition.

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain caution.

孩子

caution elements contain one or more body elements.

类似物

caution is analogous to the DocBook “caution” element.

处理

Rendered distinctly (inset and/or in a box, etc.), with the generated title “Caution” (or similar).

内容模型
(%body.elements;)+
属性

The caution element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %body.elements; parameter entity directly includes caution. The %structure.model; parameter entity indirectly includes caution.

例子

reStructuredText 资源:

.. Caution:: Don't take any wooden nickels.

Pseudo-XML 简单解析的片段:

<caution>
    <paragraph>
        Don't take any wooden nickels.

classifier

The classifier element contains the classification or type of the term being defined in a definition_list. For example, it can be used to indicate the type of a variable.

细节
类别

Body Subelements (simple)

父母

Only the definition_list_item element contains classifier.

孩子

classifier elements may contain text data plus inline elements.

类似物

classifier has no direct analogues in common DTDs. It can be emulated with primitives or type effects.

处理

See definition_list_item.

内容模型
%text.model;
属性

The classifier element contains only the common attributes: ids, names, dupnames, source, and classes.

例子

Here is a hypothetical data dictionary. reStructuredText source:

name : string
    Customer name.
i : int
    Temporary index variable.

Pseudo-XML 简单解析的片段:

<definition_list>
    <definition_list_item>
        <term>
            name
        <classifier>
            string
        <definition>
            <paragraph>
                Customer name.
    <definition_list_item>
        <term>
            i
        <classifier>
            int
        <definition>
            <paragraph>
                Temporary index variable.

contact

The contact element holds contact information for the author (individual or group) of the document, or a third-party contact. It is typically used for an email or web address.

细节
类别

Bibliographic Elements

父母

The following elements may contain contact: docinfo, authors

孩子

contact elements may contain text data plus inline elements.

类似物

contact is analogous to the DocBook “email” element. The HTML “address” element serves a similar purpose.

处理

查看 docinfo.

内容模型
%text.model;
属性

The contact element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %bibliographic.elements; parameter entity directly includes contact.

例子

reStructuredText 资源:

Document Title
==============

:Contact: jrh@example.com

解析并应用转换后完成 pseudo-XML 结果:

<document ids="document-title" names="document title">
    <title>
        Document Title
    <docinfo>
        <contact>
            <reference refuri="mailto:jrh@example.com">
                jrh@example.com

有关更完整的示例,请参阅 docinfo ,包括处理上下文。

danger

The danger element is an admonition, a distinctive and self-contained notice. Also see the other admonition elements Docutils offers (in alphabetical order): attention, caution, error, hint, important, note, tip, warning, and the generic admonition.

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain danger.

孩子

danger elements contain one or more body elements.

类似物

danger has no direct analogues in common DTDs. It can be emulated with primitives and type effects.

处理

Rendered distinctly (inset and/or in a box, etc.), with the generated title “!DANGER!” (or similar).

内容模型
(%body.elements;)+
属性

The danger element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %body.elements; parameter entity directly includes danger. The %structure.model; parameter entity indirectly includes danger.

例子

reStructuredText 资源:

.. DANGER:: Mad scientist at work!

Pseudo-XML 简单解析的片段:

<danger>
    <paragraph>
        Mad scientist at work!

date

The date element contains the date of publication, release, or last modification of the document.

细节
类别

Bibliographic Elements

父母

Only the docinfo element contains date.

孩子

date elements may contain text data plus inline elements.

类似物

date is analogous to the DocBook “date” element.

处理

Often used with the RCS/CVS keyword “Date”. See docinfo.

内容模型
%text.model;
属性

The date element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %bibliographic.elements; parameter entity directly includes date.

例子

reStructuredText 资源:

Document Title
==============

:Date: 2002-08-20

解析并应用转换后完成 pseudo-XML 结果:

<document ids="document-title" names="document title">
    <title>
        Document Title
    <docinfo>
        <date>
            2002-08-20

有关更完整的示例,请参阅 docinfo ,包括处理上下文。

decoration

The decoration element is a container for header and footer elements and potential future extensions. These elements are used for notes, time/datestamp, processing information, etc.

细节
类别

Structural Subelements

父母

Only the document element contains decoration.

孩子

decoration elements may contain decorative elements.

类似物

There are no direct analogies to decoration in HTML or in DocBook. Equivalents are typically constructed from primitives and/or generated by the processing system.

处理

See the individual decorative elements.

内容模型
(header?, footer?)

Although the content model doesn’t specifically require contents, no empty decoration elements are ever created.

属性

The decoration element contains only the common attributes: ids, names, dupnames, source, and classes.

例子

reStructuredText 资源:

A paragraph.

Complete pseudo-XML result after parsing and applying transforms, assuming that the datestamp command-line option or configuration setting has been supplied:

<document>
    <decoration>
        <footer>
            <paragraph>
                Generated on: 2002-08-20.
    <paragraph>
        A paragraph.

definition

The definition element is a container for the body elements used to define a term in a definition_list.

细节
类别

Body Subelements (compound)

父母

Only definition_list_item elements contain definition.

孩子

definition elements may contain body elements.

类似物

definition is analogous to the HTML “dd” element and to the DocBook “listitem” element (inside a “variablelistentry” element).

处理

See definition_list_item.

内容模型
(%body.elements;)+
属性

The definition element contains only the common attributes: ids, names, dupnames, source, and classes.

例子

See the examples for the definition_list, definition_list_item, and classifier elements.

definition_list

The definition_list element contains a list of terms and their definitions. It can be used for glossaries or dictionaries, to describe or classify things, for dialogues, or to itemize subtopics (such as in this reference).

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain definition_list.

孩子

definition_list elements contain one or more definition_list_item elements.

类似物

definition_list is analogous to the HTML “dl” element and to the DocBook “variablelist” element.

处理

See definition_list_item.

内容模型
(definition_list_item +)
属性

The definition_list element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %body.elements; parameter entity directly includes definition_list. The %structure.model; parameter entity indirectly includes definition_list.

例子

reStructuredText 资源:

Term
  Definition.

Term : classifier
    The ' : ' indicates a classifier in
    definition list item terms only.

Pseudo-XML 简单解析的片段:

<definition_list>
    <definition_list_item>
        <term>
            Term
        <definition>
            <paragraph>
                Definition.
    <definition_list_item>
        <term>
            Term
        <classifier>
            classifier
        <definition>
            <paragraph>
                The ' : ' indicates a classifier in
                definition list item terms only.

See definition_list_item and classifier for further examples.

definition_list_item

The definition_list_item element contains a single term/definition pair (with optional classifier).

细节
类别

Body Subelements (compound)

父母

Only the definition_list element contains definition_list_item.

孩子

definition_list_item elements each contain a single term, an optional classifier, and a definition.

类似物

definition_list_item is analogous to the DocBook “variablelistentry” element.

处理

The optional classifier can be rendered differently from the term. They should be separated visually, typically by spaces plus a colon or dash.

内容模型
(term, classifier?, definition)
属性

The definition_list_item element contains only the common attributes: ids, names, dupnames, source, and classes.

例子

reStructuredText 资源:

Tyrannosaurus Rex : carnivore
    Big and scary; the "Tyrant King".

Brontosaurus : herbivore
    All brontosauruses are thin at one end,
    much much thicker in the middle
    and then thin again at the far end.

    -- Anne Elk (Miss)

Pseudo-XML 简单解析的片段:

<definition_list>
    <definition_list_item>
        <term>
            Tyrannosaurus Rex
        <classifier>
            carnivore
        <definition>
            <paragraph>
                Big and scary; the "Tyrant King".
    <definition_list_item>
        <term>
            Brontosaurus
        <classifier>
            herbivore
        <definition>
            <paragraph>
                All brontosauruses are thin at one end,
                much much thicker in the middle
                and then thin again at the far end.
            <paragraph>
                -- Anne Elk (Miss)

See definition_list and classifier for further examples.

description

The description element contains body elements, describing the purpose or effect of a command-line option or group of options.

细节
类别

Body Subelements

父母

Only the option_list_item element contains description.

孩子

description elements may contain body elements.

类似物

description has no direct analogues in common DTDs.

处理

See option_list.

内容模型
(%body.elements;)+
属性

The description element contains only the common attributes: ids, names, dupnames, source, and classes.

例子

See the examples for the option_list element.

docinfo

The docinfo element is a container for document bibliographic data, or meta-data (data about the document). It corresponds to the front matter of a book, such as the title page and copyright page.

细节
类别

Structural Subelements

父母

Only the document element contains docinfo.

孩子

docinfo elements contain bibliographic elements.

类似物

docinfo is analogous to DocBook “info” elements (“bookinfo” etc.). There are no directly analogous HTML elements; the “meta” element carries some of the same information, albeit invisibly.

处理

The docinfo element may be rendered as a two-column table or in other styles. It may even be invisible or omitted from the processed output. Meta-data may be extracted from docinfo children; for example, HTML <meta> tags may be constructed.

When Docutils transforms a reStructuredText field_list into a docinfo element (see the examples below), RCS/CVS keywords are normally stripped from simple (one paragraph) field bodies. For complete details, please see RCS Keywords in the reStructuredText Markup Specification.

内容模型
(%bibliographic.elements;)+
属性

The docinfo element contains only the common attributes: ids, names, dupnames, source, and classes.

例子

Docinfo is represented in reStructuredText by a field_list in a bibliographic context: the first non-comment element of a document, after any document title/subtitle. The field list is transformed into a docinfo element and its children by a transform. Source:

Docinfo Example
===============

:Author: J. Random Hacker
:Contact: jrh@example.com
:Date: 2002-08-18
:Status: Work In Progress
:Version: 1
:Filename: $RCSfile$
:Copyright: This document has been placed in the public domain.

解析并应用转换后完成 pseudo-XML 结果:

<document ids="docinfo-example" names="docinfo example">
    <title>
        Docinfo Example
    <docinfo>
        <author>
            J. Random Hacker
        <contact>
            <reference refuri="mailto:jrh@example.com">
                jrh@example.com
        <date>
            2002-08-18
        <status>
            Work In Progress
        <version>
            1
        <field>
            <field_name>
                Filename
            <field_body>
                <paragraph>
                    doctree.txt
        <copyright>
            This document has been placed in the public domain.

Note that “Filename” is a non-standard docinfo field, so becomes a generic field element. Also note that the “RCSfile” keyword syntax has been stripped from the “Filename” data.

See field_list for an example in a non-bibliographic context. Also see the individual examples for the various bibliographic elements.

doctest_block

The doctest_block element is a Python-specific variant of literal_block. It is a block of text where line breaks and whitespace are significant and must be preserved. doctest_block elements are used for interactive Python interpreter sessions, which are distinguished by their input prompt: >>>. They are meant to illustrate usage by example, and provide an elegant and powerful testing environment via the doctest module in the Python standard library.

细节
类别

Simple Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain doctest_block.

孩子

doctest_block elements may contain text data plus inline elements.

类似物

doctest_block is analogous to the HTML “pre” element and to the DocBook “programlisting” and “screen” elements.

处理

As with literal_block, doctest_block elements are typically rendered in a monospaced typeface. It is crucial that all whitespace and line breaks are preserved in the rendered form.

内容模型
%text.model;
属性

The doctest_block element contains the common attributes (ids, names, dupnames, source, and classes), plus xml:space.

参数实体

The %body.elements; parameter entity directly includes doctest_block. The %structure.model; parameter entity indirectly includes doctest_block.

例子

reStructuredText 资源:

This is an ordinary paragraph.

>>> print 'this is a Doctest block'
this is a Doctest block

Pseudo-XML 简单解析的片段:

<paragraph>
    This is an ordinary paragraph.
<doctest_block xml:space="preserve">
    >>> print 'this is a Doctest block'
    this is a Doctest block

document

The document element is the root (topmost) element of the Docutils document tree. document is the direct or indirect ancestor of every other element in the tree. It encloses the entire document tree. It is the starting point for a document.

细节
类别

Structural Elements

父母

The document element has no parents.

孩子

document elements may contain structural subelements, structural elements, and body elements.

类似物

document is analogous to the HTML “html” element and to several DocBook elements such as “book”.

内容模型
( (title, subtitle?)?,
  decoration?,
  (docinfo, transition?)?,
  %structure.model; )

Depending on the source of the data and the stage of processing, the “document” may not initially contain a “title”. A document title is not directly representable in reStructuredText. Instead, a lone top-level section may have its title promoted to become the document title, and similarly for a lone second-level (sub)section’s title to become the document subtitle.

The contents of “decoration” may be specified in a document, constructed programmatically, or both. The “docinfo” may be transformed from an initial field_list.

See the %structure.model; parameter entity for details of the body of a document.

属性

The document element contains the common attributes (ids, names, dupnames, source, and classes), plus an optional title attribute which stores the document title metadata.

例子

reStructuredText 资源:

A Title
=======

A paragraph.

Complete pseudo-XML result from simple parsing:

<document>
    <section ids="a-title" names="a title">
        <title>
            A Title
        <paragraph>
            A paragraph.

After applying transforms, the section title is promoted to become the document title:

<document ids="a-title" names="a title">
    <title>
        A Title
    <paragraph>
        A paragraph.

entry

To be completed.

enumerated_list

The enumerated_list element contains list_item elements which are uniformly marked with enumerator labels.

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain enumerated_list.

孩子

enumerated_list elements contain one or more list_item elements.

类似物

enumerated_list is analogous to the HTML “ol” element and to the DocBook “orderedlist” element.

处理

Each list item should begin a new vertical block, prefaced by a enumeration marker (such as “1.”).

内容模型
(list_item +)
属性

The enumerated_list element contains the common attributes (ids, names, dupnames, source, and classes), plus enumtype, prefix, suffix, and start.

enumtype is used to record the intended enumeration sequence, one of “arabic” (1, 2, 3, …), “loweralpha” (a, b, c, …, z), “upperalpha” (A, B, C, …, Z), “lowerroman” (i, ii, iii, iv, …, mmmmcmxcix [4999]), or “upperroman” (I, II, III, IV, …, MMMMCMXCIX [4999]).

prefix stores the formatting characters used before the enumerator. In documents originating from reStructuredText data, it will contain either “” (empty string) or “(” (left parenthesis). It may or may not affect processing.

suffix stores the formatting characters used after the enumerator. In documents originating from reStructuredText data, it will contain either “.” (period) or “)” (right parenthesis). Depending on the capabilities of the output format, this attribute may or may not affect processing.

start contains the ordinal value of the first item in the list, in decimal. For lists beginning at value 1 (“1”, “a”, “A”, “i”, or “I”), this attribute may be omitted.

参数实体

The %body.elements; parameter entity directly includes enumerated_list. The %structure.model; parameter entity indirectly includes enumerated_list.

例子

reStructuredText 资源:

1. Item 1.

   (A) Item A.
   (B) Item B.
   (C) Item C.

2. Item 2.

Pseudo-XML 简单解析的片段:

<enumerated_list enumtype="arabic" prefix="" suffix=".">
    <list_item>
        <paragraph>
            Item 1.
        <enumerated_list enumtype="upperalpha" prefix="(" suffix=")">
            <list_item>
                <paragraph>
                    Item A.
            <list_item>
                <paragraph>
                    Item B.
            <list_item>
                <paragraph>
                    Item C.
    <list_item>
        <paragraph>
            Item 2.

See list_item for another example.

error

The error element is an admonition, a distinctive and self-contained notice. Also see the other admonition elements Docutils offers (in alphabetical order): attention, caution, danger, hint, important, note, tip, warning, and the generic admonition.

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain error.

孩子

error elements contain one or more body elements.

类似物

error has no direct analogues in common DTDs. It can be emulated with primitives and type effects.

处理

Rendered distinctly (inset and/or in a box, etc.), with the generated title “Error” (or similar).

内容模型
(%body.elements;)+
属性

The error element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %body.elements; parameter entity directly includes error. The %structure.model; parameter entity indirectly includes error.

例子

reStructuredText 资源:

.. Error:: Does not compute.

Pseudo-XML 简单解析的片段:

<error>
    <paragraph>
        Does not compute.

field

The field element contains a pair of field_name and field_body elements.

细节
类别

Body Subelements

父母

The following elements may contain field: docinfo, field_list

孩子

Each field element contains one field_name and one field_body element.

类似物

field has no direct analogues in common DTDs.

处理

See field_list.

内容模型
(field_name, field_body)
属性

The field element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %bibliographic.elements; parameter entity directly includes field.

例子

See the examples for the field_list and docinfo elements.

field_body

The field_body element contains body elements. It is analogous to a database field’s data.

细节
类别

Body Subelements

父母

Only the field element contains field_body.

孩子

field_body elements may contain body elements.

类似物

field_body has no direct analogues in common DTDs.

处理

See field_list.

内容模型
(%body.elements;)*
属性

The field_body element contains only the common attributes: ids, names, dupnames, source, and classes.

例子

See the examples for the field_list and docinfo elements.

field_list

The field_list element contains two-column table-like structures resembling database records (label & data pairs). Field lists are often meant for further processing. In reStructuredText, field lists are used to represent bibliographic fields (contents of the docinfo element) and directive options.

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain field_list.

孩子

field_list elements contain one or more field elements.

类似物

field_list has no direct analogues in common DTDs. It can be emulated with primitives such as tables.

处理

A field_list is typically rendered as a two-column list, where the first column contains “labels” (usually with a colon suffix). However, field lists are often used for extension syntax or special processing. Such structures do not survive as field lists to be rendered.

内容模型
(field +)
属性

The field_list element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %body.elements; parameter entity directly includes field_list. The %structure.model; parameter entity indirectly includes field_list.

例子

reStructuredText 资源:

:Author: Me
:Version: 1
:Date: 2001-08-11
:Parameter i: integer

Pseudo-XML 简单解析的片段:

<field_list>
    <field>
        <field_name>
            Author
        <field_body>
            <paragraph>
                Me
    <field>
        <field_name>
            Version
        <field_body>
            <paragraph>
                1
    <field>
        <field_name>
            Date
        <field_body>
            <paragraph>
                2001-08-11
    <field>
        <field_name>
            Parameter i
        <field_body>
            <paragraph>
                integer

field_name

The field_name element contains text; it is analogous to a database field’s name.

细节
类别

Body Subelements (simple)

父母

Only the field element contains field_name.

孩子

field_name elements may contain text data plus inline elements.

类似物

field_name has no direct analogues in common DTDs.

处理

See field_list.

内容模型
%text.model;
属性

The field_name element contains only the common attributes: ids, names, dupnames, source, and classes.

例子

See the examples for the field_list and docinfo elements.

generated

Docutils wraps generated elements around text that is inserted (generated) by Docutils; i.e., text that was not in the document, like section numbers inserted by the “sectnum” directive.

To be completed.

hint

The hint element is an admonition, a distinctive and self-contained notice. Also see the other admonition elements Docutils offers (in alphabetical order): attention, caution, danger, error, important, note, tip, warning, and the generic admonition.

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain hint.

孩子

hint elements contain one or more body elements.

类似物

hint has no direct analogues in common DTDs. It can be emulated with primitives and type effects.

处理

Rendered distinctly (inset and/or in a box, etc.), with the generated title “Hint” (or similar).

内容模型
(%body.elements;)+
属性

The hint element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %body.elements; parameter entity directly includes hint. The %structure.model; parameter entity indirectly includes hint.

例子

reStructuredText 资源:

.. Hint:: It's bigger than a bread box.

Pseudo-XML 简单解析的片段:

<hint>
    <paragraph>
        It's bigger than a bread box.

important

The important element is an admonition, a distinctive and self-contained notice. Also see the other admonition elements Docutils offers (in alphabetical order): attention, caution, danger, error, hint, note, tip, warning, and the generic admonition.

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain important.

孩子

important elements contain one or more body elements.

类似物

important is analogous to the DocBook “important” element.

处理

Rendered distinctly (inset and/or in a box, etc.), with the generated title “Important” (or similar).

内容模型
(%body.elements;)+
属性

The important element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %body.elements; parameter entity directly includes important. The %structure.model; parameter entity indirectly includes important.

例子

reStructuredText 资源:

.. Important::

   * Wash behind your ears.
   * Clean up your room.
   * Back up your data.
   * Call your mother.

Pseudo-XML 简单解析的片段:

<important>
    <bullet_list>
        <list_item>
            <paragraph>
                Wash behind your ears.
        <list_item>
            <paragraph>
                Clean up your room.
        <list_item>
            <paragraph>
                Back up your data.
        <list_item>
            <paragraph>
                Call your mother.

line

The line element contains a single line of text, part of a line_block.

细节
类别

Body Subelements (simple)

父母

Only the line_block element contains line.

孩子

line elements may contain text data plus inline elements.

类似物

line has no direct analogues in common DTDs. It can be emulated with primitives or type effects.

处理

See line_block.

内容模型
%text.model;
属性

The line element contains the common attributes (ids, names, dupnames, source, and classes), plus xml:space.

例子

See line_block.

line_block

The line_block element contains a sequence of lines and nested line blocks. Line breaks (implied between elements) and leading whitespace (indicated by nesting) is significant and must be preserved. line_block elements are commonly used for verse and addresses. See literal_block for an alternative useful for program listings and interactive computer sessions.

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain line_block.

孩子

line_block elements may contain line elements and nested line_block elements.

类似物

line_block is analogous to the DocBook “literallayout” element and to the HTML “pre” element (with modifications to typeface styles).

处理

Unlike literal_block, line_block elements are typically rendered in an ordinary text typeface. It is crucial that leading whitespace and line breaks are preserved in the rendered form.

内容模型
(line | line_block)+
属性

The line_block element contains the common attributes (ids, names, dupnames, source, and classes), plus xml:space.

参数实体

The %body.elements; parameter entity directly includes line_block. The %structure.model; parameter entity indirectly includes line_block.

例子

reStructuredText uses a directive to indicate a line_block. Example source:

Take it away, Eric the Orchestra Leader!

| A one, two, a one two three four
|
| Half a bee, philosophically,
|     must, *ipso facto*, half not be.
| But half the bee has got to be,
|     *vis a vis* its entity.  D'you see?
|
| But can a bee be said to be
|     or not to be an entire bee,
|         when half the bee is not a bee,
|             due to some ancient injury?
|
| Singing...

Pseudo-XML 简单解析的片段:

<paragraph>
    Take it away, Eric the Orchestra Leader!
<line_block>
    <line>
        A one, two, a one two three four
    <line>
    <line>
        Half a bee, philosophically,
    <line_block>
        <line>
            must,
            <emphasis>
                ipso facto
            , half not be.
    <line>
        But half the bee has got to be,
    <line_block>
        <line>
            <emphasis>
                vis a vis
             its entity.  D'you see?
        <line>
    <line>
        But can a bee be said to be
    <line_block>
        <line>
            or not to be an entire bee,
        <line_block>
            <line>
                when half the bee is not a bee,
            <line_block>
                <line>
                    due to some ancient injury?
                <line>
    <line>
        Singing...

list_item

The list_item element is a container for the elements of a list item.

细节
类别

Body Subelements (compound)

父母

The bullet_list and enumerated_list elements contain list_item.

孩子

list_item elements may contain body elements.

类似物

list_item is analogous to the HTML “li” element and to the DocBook “listitem” element.

处理

See bullet_list or enumerated_list.

内容模型
(%body.elements;)*
属性

The list_item element contains only the common attributes: ids, names, dupnames, source, and classes.

例子

reStructuredText 资源:

1. Outer list, item 1.

   * Inner list, item 1.
   * Inner list, item 2.

2. Outer list, item 2.

Pseudo-XML 简单解析的片段:

<enumerated_list enumtype="arabic" prefix="" suffix=".">
    <list_item>
        <paragraph>
            Outer list, item 1.
        <bullet_list bullet="*">
            <list_item>
                <paragraph>
                    Inner list, item 1.
            <list_item>
                <paragraph>
                    Inner list, item 2.
    <list_item>
        <paragraph>
            Outer list, item 2.

See bullet_list or enumerated_list for further examples.

literal_block

The literal_block element contains a block of text where line breaks and whitespace are significant and must be preserved. literal_block elements are commonly used for program listings and interactive computer sessions. See line_block for an alternative useful for verse and addresses.

细节
类别

Simple Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain literal_block.

孩子

literal_block elements may contain text data plus inline elements.

类似物

literal_block is analogous to the HTML “pre” element and to the DocBook “programlisting” and “screen” elements.

处理

literal_block elements are typically rendered in a monospaced typeface. It is crucial that all whitespace and line breaks are preserved in the rendered form.

内容模型
%text.model;
属性

The literal_block element contains the common attributes (ids, names, dupnames, source, and classes), plus xml:space.

参数实体

The %body.elements; parameter entity directly includes literal_block. The %structure.model; parameter entity indirectly includes literal_block.

例子

reStructuredText 资源:

Here is a literal block::

    if literal_block:
        text = 'is left as-is'
        spaces_and_linebreaks = 'are preserved'
        markup_processing = None

Pseudo-XML 简单解析的片段:

<paragraph>
    Here is a literal block:
<literal_block xml:space="preserve">
    if literal_block:
        text = 'is left as-is'
        spaces_and_linebreaks = 'are preserved'
        markup_processing = None

math

The math element contains text in LaTeX math format 1 that is typeset as mathematical notation (inline formula).

If the output format does not support math typesetting, the content is inserted verbatim.

细节
类别

Inline Elements

父母

All elements employing the %inline.elements; parameter entities in their content models may contain math.

孩子

math elements may contain text data.

类似物

math is analogous to a MathML “math” element or the LaTeX ($ math $) mode.

处理

Rendered as mathematical notation.

内容模型
%text.model;
属性

The math element contains the common attributes (ids, names, dupnames, source, and classes).

1(1,2)

For details of the supported mathematical language, see the “math” directive

math_block

The math_block element contains a block of text in LaTeX math format 1 that is typeset as mathematical notation (display formula). The math_block element is generated during the initial parse from a “math” directive.

If the output format does not support math typesetting, the content is inserted verbatim.

细节
类别

Simple Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain math_block.

孩子

math_block elements may contain text data.

类似物

math_block is analogous to a LaTeX “equation*” environment or a MathML “math” element displayed as block-level element.

处理

Rendered in a block as mathematical notation, typically centered or with indentation

内容模型
(#PCDATA)
属性

The math element contains the common attributes (ids, names, dupnames, source, and classes).

note

The note element is an admonition, a distinctive and self-contained notice. Also see the other admonition elements Docutils offers (in alphabetical order): attention, caution, danger, error, hint, important, tip, warning, and the generic admonition.

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain note.

孩子

note elements contain one or more body elements.

类似物

note is analogous to the DocBook “note” element.

处理

Rendered distinctly (inset and/or in a box, etc.), with the generated title “Note” (or similar).

内容模型
(%body.elements;)+
属性

The note element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %body.elements; parameter entity directly includes note. The %structure.model; parameter entity indirectly includes note.

例子

reStructuredText 资源:

.. Note:: Admonitions can be handy to break up a
   long boring technical document.

Pseudo-XML 简单解析的片段:

<note>
    <paragraph>
        Admonitions can be handy to break up a
        long boring technical document.

option

The option element groups an option string together with zero or more option argument placeholders. Note that reStructuredText currently supports only one argument per option.

细节
类别

Body Subelements

父母

Only the option_group element contains option.

孩子

Each option element contains one option_string and zero or more option_argument elements.

类似物

option has no direct analogues in common DTDs.

处理

See option_list.

内容模型
(option_string, option_argument *)
属性

The option element contains only the common attributes: ids, names, dupnames, source, and classes.

例子

See the examples for the option_list element.

option_argument

The option_argument element contains placeholder text for option arguments.

细节
类别

Body Subelements

父母

Only the option element contains option_argument.

孩子

option_argument elements contain text data only.

类似物

option_argument has no direct analogues in common DTDs.

处理

The value of the “delimiter” attribute is prefixed to the option_argument, separating it from its option_string or a preceding option_argument. The option_argument text is typically rendered in a monospaced typeface, possibly italicized or otherwise altered to indicate its placeholder nature.

内容模型
(#PCDATA)
属性

The option_argument element contains the common attributes (ids, names, dupnames, source, and classes), plus delimiter.

delimiter contains the text preceding the option_argument: either the text separating it from the option_string (typically either “=” or ” “) or the text between option arguments (typically either “,” or ” “).

例子

See the examples for the option_list element.

option_group

The option_group element groups together one or more option elements, all synonyms.

细节
类别

Body Subelements

父母

Only the option_list_item element contains option_group.

孩子

option_group elements contain one or more option elements.

option_group is an empty element and has no children.

Each option_group element contains one _ and one _ element.

类似物

option_group has no direct analogues in common DTDs.

处理

Typically option elements within an option_group are joined together in a comma-separated list.

内容模型
(option_group, description)
属性

The option_group element contains only the common attributes: ids, names, dupnames, source, and classes.

例子

See the examples for the option_list element.

option_list

Each option_list element contains a two-column list of command-line options and descriptions, documenting a program’s options.

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain option_list.

孩子

option_list elements contain one or more option_list_item elements.

类似物

option_list has no direct analogues in common DTDs. It can be emulated with primitives such as tables.

处理

An option_list is typically rendered as a two-column list, where the first column contains option strings and arguments, and the second column contains descriptions.

内容模型
(option_list_item +)
属性

The option_list element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %body.elements; parameter entity directly includes option_list. The %structure.model; parameter entity indirectly includes option_list.

例子

reStructuredText 资源:

-a            command-line option "a"
-1 file, --one=file, --two file
              Multiple options with arguments.

Pseudo-XML 简单解析的片段:

<option_list>
    <option_list_item>
        <option_group>
            <option>
                <option_string>
                    -a
        <description>
            <paragraph>
                command-line option "a"
    <option_list_item>
        <option_group>
            <option>
                <option_string>
                    -1
                <option_argument delimiter=" ">
                    file
            <option>
                <option_string>
                    --one
                <option_argument delimiter="=">
                    file
            <option>
                <option_string>
                    --two
                <option_argument delimiter=" ">
                    file
        <description>
            <paragraph>
                Multiple options with arguments.

option_list_item

The option_list_item element is a container for a pair of option_group and description elements.

细节
类别

Body Subelements

父母

Only the option_list element contains option_list_item.

孩子

Each option_list_item element contains one option_group and one description element.

类似物

option_list_item has no direct analogues in common DTDs.

处理

See option_list.

内容模型
(option_group, description)
属性

The option_list_item element contains only the common attributes: ids, names, dupnames, source, and classes.

例子

See the examples for the option_list element.

option_string

The option_string element contains the text of a command-line option.

细节
类别

Body Subelements

父母

Only the option element contains option_string.

孩子

option_string elements contain text data only.

类似物

option_string has no direct analogues in common DTDs.

处理

The option_string text is typically rendered in a monospaced typeface.

内容模型
(#PCDATA)
属性

The option_string element contains only the common attributes: ids, names, dupnames, source, and classes.

例子

See the examples for the option_list element.

organization

The organization element contains the name of document author’s organization, or the organization responsible for the document.

细节
类别

Bibliographic Elements

父母

Only the docinfo element contains organization.

孩子

organization elements may contain text data plus inline elements.

类似物

organization is analogous to the DocBook “orgname”, “corpname”, or “publishername” elements.

处理

查看 docinfo.

内容模型
%text.model;
属性

The organization element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %bibliographic.elements; parameter entity directly includes organization.

例子

reStructuredText 资源:

Document Title
==============

:Organization: Humankind

解析并应用转换后完成 pseudo-XML 结果:

<document ids="document-title" names="document title">
    <title>
        Document Title
    <docinfo>
        <organization>
            Humankind

有关更完整的示例,请参阅 docinfo ,包括处理上下文。

paragraph

The paragraph element contains the text and inline elements of a single paragraph, a fundamental building block of documents.

细节
类别

Simple Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain paragraph.

孩子

paragraph elements may contain text data plus inline elements.

类似物

paragraph is analogous to the HTML “p” element and to the DocBook “para” elements.

内容模型
%text.model;
属性

The paragraph element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %body.elements; parameter entity directly includes paragraph. The %structure.model; parameter entity indirectly includes paragraph.

例子

reStructuredText 资源:

A paragraph.

Pseudo-XML 简单解析的片段:

<paragraph>
    A paragraph.

revision

The revision element contains the revision number of the document. It can be used alone or in conjunction with version.

细节
类别

Bibliographic Elements

父母

Only the docinfo element contains revision.

孩子

revision elements may contain text data plus inline elements.

类似物

revision is analogous to but simpler than the DocBook “revision” element. It closely matches the DocBook “revnumber” element, but in a simpler context.

处理

Often used with the RCS/CVS keyword “Revision”. See docinfo.

内容模型
%text.model;
属性

The revision element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %bibliographic.elements; parameter entity directly includes revision.

例子

reStructuredText 资源:

Document Title
==============

:Version: 1
:Revision: b

解析并应用转换后完成 pseudo-XML 结果:

<document ids="document-title" names="document title">
    <title>
        Document Title
    <docinfo>
        <version>
            1
        <revision>
            b

有关更完整的示例,请参阅 docinfo ,包括处理上下文。

rubric

rubric n. 1. a title, heading, or the like, in a manuscript, book, statute, etc., written or printed in red or otherwise distinguished from the rest of the text. …

—Random House Webster’s College Dictionary, 1991

A rubric is like an informal heading that doesn’t correspond to the document’s structure.

To be completed.

section

The section element is the main unit of hierarchy for Docutils documents. Docutils section elements are a recursive structure; a section may contain other section elements, without limit. Paragraphs and other body elements may occur before a section, but not after it.

细节
类别

Structural Elements

父母

The following elements may contain section: document, section

孩子

section elements begin with a title, and may contain body elements as well as transition, topic, and sidebar elements.

类似物

section is analogous to DocBook recursive “section” elements, and to HTML “div” elements combined with “h1” etc. title elements.

内容模型
(title,
 %structure.model;)

See the %structure.model; parameter entity for details of the body of a section.

属性

The section element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %section.elements; parameter entity directly includes section. The %structure.model; parameter entity indirectly includes section.

例子

reStructuredText 资源:

Title 1
=======
Paragraph 1.

Title 2
-------
Paragraph 2.

Title 3
=======
Paragraph 3.

Title 4
-------
Paragraph 4.

Complete pseudo-XML result after parsing:

<document>
    <section ids="title-1" names="title 1">
        <title>
            Title 1
        <paragraph>
            Paragraph 1.
        <section ids="title-2" names="title 2">
            <title>
                Title 2
            <paragraph>
                Paragraph 2.
    <section ids="title-3" names="title 3">
        <title>
            Title 3
        <paragraph>
            Paragraph 3.
        <section ids="title-4" names="title 4">
            <title>
                Title 4
            <paragraph>
                Paragraph 4.

status

The status element contains a status statement for the document, such as “Draft”, “Final”, “Work In Progress”, etc.

细节
类别

Bibliographic Elements

父母

Only the docinfo element contains status.

孩子

status elements may contain text data plus inline elements.

类似物

status is analogous to the DocBook “status” element.

处理

查看 docinfo.

内容模型
%text.model;
属性

The status element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %bibliographic.elements; parameter entity directly includes status.

例子

reStructuredText 资源:

Document Title
==============

:Status: Work In Progress

解析并应用转换后完成 pseudo-XML 结果:

<document ids="document-title" names="document title">
    <title>
        Document Title
    <docinfo>
        <status>
            Work In Progress

有关更完整的示例,请参阅 docinfo ,包括处理上下文。

subtitle

The subtitle element stores the subtitle of a document.

细节
类别

Structural Subelements

父母

The document and sidebar elements may contain subtitle.

孩子

subtitle elements may contain text data plus inline elements.

类似物

subtitle is analogous to HTML header elements (“h2” etc.) and to the DocBook “subtitle” element.

处理

A document’s subtitle is usually rendered smaller than its title.

内容模型
%text.model;
属性

The subtitle element contains only the common attributes: ids, names, dupnames, source, and classes.

例子

reStructuredText 资源:

=======
 Title
=======
----------
 Subtitle
----------

A paragraph.

解析并应用转换后完成 pseudo-XML 结果:

<document ids="title" names="title">
    <title>
        Title
    <subtitle ids="subtitle" names="subtitle">
        Subtitle
    <paragraph>
        A paragraph.

Note how two section levels have collapsed, promoting their titles to become the document’s title and subtitle. Since there is only one structural element (document), the subsection’s ids and names attributes are stored in the subtitle element.

表格

Docutils tables are based on the Exchange subset of the CALS-table model (OASIS Technical Memorandum 9901:1999 “XML Exchange Table Model DTD”, http://www.oasis-open.org/html/tm9901.htm).

To be completed.

term

The term element contains a word or phrase being defined in a definition_list.

细节
类别

Body Subelements (simple)

父母

只有 definition_list_item 元素包含 term

孩子

term 元素可能包含文本数据和 inline elements

类似物

term is analogous to the HTML “dt” element and to the DocBook “term” element.

处理

See definition_list_item.

内容模型
%text.model;
属性

The term element contains only the common attributes: ids, names, dupnames, source, and classes.

例子

See the examples for the definition_list, definition_list_item, and classifier elements.

tip

The tip element is an admonition, a distinctive and self-contained notice. Also see the other admonition elements Docutils offers (in alphabetical order): attention, caution, danger, error, hint, important, note, warning, and the generic admonition.

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain tip.

孩子

tip elements contain one or more body elements.

类似物

tip is analogous to the DocBook “tip” element.

处理

Rendered distinctly (inset and/or in a box, etc.), with the generated title “Tip” (or similar).

内容模型
(%body.elements;)+
属性

The tip element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %body.elements; parameter entity directly includes tip. The %structure.model; parameter entity indirectly includes tip.

例子

reStructuredText 资源:

.. Tip:: 15% if the service is good.

Pseudo-XML 简单解析的片段:

<tip>
    <paragraph>
        15% if the service is good.

title

The title element stores the title of a document, section, topic, sidebar, or generic admonition.

细节
类别

Structural Subelements

父母

The following elements may contain title: document, section, topic, sidebar, admonition

孩子

title elements may contain text data plus inline elements.

类似物

title is analogous to HTML “title” and header (“h1” etc.) elements, and to the DocBook “title” element.

内容模型
%text.model;
属性

The title element contains the common attributes (ids, names, dupnames, source, and classes), plus refid and auto.

refid is used as a backlink to a table of contents entry.

auto is used to indicate (with value “1”) that the title has been numbered automatically.

例子

reStructuredText 资源:

A Title
=======

A paragraph.

Pseudo-XML 简单解析的片段:

<section ids="a-title" names="a title">
    <title>
        A Title
    <paragraph>
        A paragraph.

topic

The topic element is a nonrecursive section-like construct which may occur at the top level of a section wherever a body element (list, table, etc.) is allowed. In other words, topic elements cannot nest inside body elements, so you can’t have a topic inside a table or a list, or inside another topic.

细节
类别

Structural Elements

父母

The following elements may contain topic: document, section, sidebar

孩子

topic elements begin with a title and may contain body elements.

类似物

topic is analogous to the DocBook “simplesect” element.

处理

A topic element should be set off from the rest of the document somehow, such as with indentation or a border.

内容模型
(title?,
 (%body.elements;)+)
属性

The topic element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %structure.model; parameter entity directly includes topic.

例子

The “topic” directive is used to create a topic element. reStructuredText source:

.. topic:: Title

   Body.

Pseudo-XML 简单解析的片段:

<topic>
    <title>
        Title
    <paragraph>
        Body.

transition

The transition element is commonly seen in novels and short fiction, as a gap spanning one or more lines, with or without a type ornament such as a row of asterisks. Transitions separate body elements and sections, dividing a section into untitled divisions. A transition may not begin or end a section 2 or document, nor may two transitions be immediately adjacent.

See Doctree Representation of Transitions in A Record of reStructuredText Syntax Alternatives.

2

In reStructuredText markup, a transition may appear to fall at the end of a section immediately before another section. A transform recognizes this case and moves the transition so it separates the sections.

细节
类别

Structural Subelements

父母

The following elements may contain transition: document, section

孩子

transition is an empty element and has no children.

类似物

transition is analogous to the HTML “hr” element.

处理

The transition element is typically rendered as vertical whitespace (more than that separating paragraphs), with or without a horizontal line or row of asterisks. In novels, transitions are often represented as a row of three well-spaced asterisks with vertical space above and below.

内容模型
EMPTY

The transition element has no content; it is a “point element”.

属性

The transition element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %structure.model; parameter entity directly includes transition.

例子

reStructuredText 资源:

Paragraph 1.

--------

Paragraph 2.

Complete pseudo-XML result after parsing:

<document>
    <paragraph>
        Paragraph 1.
    <transition>
    <paragraph>
        Paragraph 2.

version

The version element contains the version number of the document. It can be used alone or in conjunction with revision.

细节
类别

Bibliographic Elements

父母

Only the docinfo element contains version.

孩子

version elements may contain text data plus inline elements.

类似物

version may be considered analogous to the DocBook “revision”, “revnumber”, or “biblioid” elements.

处理

Sometimes used with the RCS/CVS keyword “Revision”. See docinfo and revision.

内容模型
%text.model;
属性

The version element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %bibliographic.elements; parameter entity directly includes version.

例子

reStructuredText 资源:

Document Title
==============

:Version: 1.1

解析并应用转换后完成 pseudo-XML 结果:

<document ids="document-title" names="document title">
    <title>
        Document Title
    <docinfo>
        <version>
            1.1

有关更完整的示例,请参阅 docinfo ,包括处理上下文。

warning

The warning element is an admonition, a distinctive and self-contained notice. Also see the other admonition elements Docutils offers (in alphabetical order): attention, caution, danger, error, hint, important, note, tip.

细节
类别

Compound Body Elements

父母

All elements employing the %body.elements; or %structure.model; parameter entities in their content models may contain warning.

孩子

warning elements contain one or more body elements.

类似物

warning is analogous to the DocBook “warning” element.

处理

Rendered distinctly (inset and/or in a box, etc.), with the generated title “Warning” (or similar).

内容模型
(%body.elements;)+
属性

The warning element contains only the common attributes: ids, names, dupnames, source, and classes.

参数实体

The %body.elements; parameter entity directly includes warning. The %structure.model; parameter entity indirectly includes warning.

例子

reStructuredText 资源:

.. WARNING:: Reader discretion is strongly advised.

Pseudo-XML 简单解析的片段:

<warning>
    <paragraph>
        Reader discretion is strongly advised.

Attribute Reference

Common Attributes: Through the %basic.atts; parameter entity, all elements contain the following attributes: ids, names, dupnames, source, and classes.

Attribute types:

CDATA

Character data. CDATA attributes may contain arbitrary text.

ID

Like a NMTOKEN, but it must begin with a letter (a “name production”). Identical ID values must not appear more than once in a document; i.e., ID values must uniquely identify their elements.

IDREF

A reference to an ID value (a name production) of another element.

IDREFS

One or more space-separated ID references (name productions).

NMTOKEN

A “name token”. One or more of letters, digits, “.”, “-“, and “_”.

NMTOKENS

One or more space-separated NMTOKEN names.

%yesorno;

No if zero (“0”), yes if any other value. This is a parameter entity which resolves to a NMTOKEN attribute type.

%number;

This emphasizes that the attribute value must be a number. This is a parameter entity which resolves to a NMTOKEN attribute type.

enumeration

The attribute value may be one of a specified list of values.

anonymous

Attribute type: %yesorno;. Default value: none (implies no).

The anonymous attribute is used for unnamed hyperlinks in the target and reference elements (via the %anonymous.att; parameter entity).

auto

Attribute type: CDATA. Default value: none.

The auto attribute is used to indicate automatically-numbered footnote, footnote_reference and title elements (via the %auto.att; parameter entity).

backrefs

Attribute type: IDREFS. Default value: none.

The backrefs attribute contains a space-separated list of ids references, used for backlinks from footnote, citation, and system_message elements (via the %backrefs.att; parameter entity).

bullet

Attribute type: CDATA. Default value: none.

The bullet attribute is used in the bullet_list element.

classes

Attribute type: NMTOKENS. Default value: none.

The classes attribute is a list containing zero or more names used to classify an element. The names are converted to conform to the regular expression [a-z](-?[a-z0-9]+)* (see the “class” directive description for details and rationale).

The purpose of the attribute is to indicate an “is-a” variant relationship, to allow an extensible way of defining sub-classes of existing elements. It can be used to carry context forward between a Docutils Reader and Writer, when a custom structure is reduced to a standardized document tree. One common use is in conjunction with stylesheets, to add selection criteria. It should not be used to carry formatting instructions or arbitrary content.

The classes attribute’s contents should be ignorable. Writers that are not familiar with the variant expressed should be able to ignore the attribute.

classes is one of the common attributes, shared by all Docutils elements.

delimiter

Attribute type: CDATA. Default value: none.

The delimiter attribute is used in the option_argument element.

dupnames

Attribute type: CDATA. Default value: none.

The dupnames attribute is a list containing the names of an element when there has been a naming conflict. The contents of the dupnames attribute would have been transferred from the names attribute. An element may have at most one of the names or dupnames attributes, but not both. dupnames is one of the common attributes, shared by all Docutils elements.

enumtype

Attribute type: enumeration, one of “arabic”, “loweralpha”, “upperalpha”, “lowerroman”, or “upperroman”. Default value: none.

The enumtype attribute is used in the enumerated_list element.

ids

Attribute type: NMTOKENS. Default value: none.

The ids attribute is a list containing one or more unique identifier keys. ids is one of the common attributes, shared by all Docutils elements.

names

Attribute type: CDATA. Default value: none.

The names attribute is a list containing the names of an element, typically originating from the element’s title or content. Each name in names must be unique; if there are name conflicts (two or more elements want to the same name), the contents will be transferred to the dupnames attribute on the duplicate elements. An element may have at most one of the names or dupnames attributes, but not both. names is one of the common attributes, shared by all Docutils elements.

prefix

Attribute type: CDATA. Default value: none.

The prefix attribute is used in the enumerated_list element.

refid

Attribute type: IDREF. Default value: none.

The refid attribute contains references to ids attributes in other elements. It is used by the target, reference, footnote_reference, citation_reference, title and problematic elements (via the %refid.att; and %reference.atts; parameter entities).

refname

Attribute type: NMTOKENS. Default value: none.

The refname attribute contains an internal reference to the names attribute of another element. On a target element, refname indicates an indirect target which may resolve to either an internal or external reference. refname is used by the target, reference, footnote_reference, citation_reference, and substitution_reference elements (via the %refname.att; and %reference.atts; parameter entities).

refuri

Attribute type: CDATA. Default value: none.

The refuri attribute contains an external reference to a URI/URL. It is used by the target, reference, footnote_reference, and citation_reference elements (via the %reference.atts; parameter entity).

source

Attribute type: CDATA. Default value: none.

The source attribute is used to store the path or URL to the source text that was used to produce the document tree. It is one of the common attributes, shared by all Docutils elements.

start

Attribute type: %number;. Default value: none.

The start attribute is used in the enumerated_list element.

suffix

Attribute type: CDATA. Default value: none.

The suffix attribute is used in the enumerated_list element.

xml:space

Attribute type: one of “default” or “preserve”. Default value: “preserve” (fixed).

The xml:space attribute is a standard XML attribute for whitespace-preserving elements. It is used by the literal_block, line_block, doctest_block, comment, and raw elements (via the %fixedspace.att; parameter entity). It is a fixed attribute, meant to communicate to an XML parser that the element contains significant whitespace. The attribute value should not be set in a document instance.

title

Attribute type: CDATA. Default value: none.

The title attribute stores the title metadata of a document. This title is typically not part of the rendered document. It may for example be used in HTML’s title element.

Parameter Entity Reference

Parameter entities are used to simplify the DTD (to share definitions and reduce duplication) and to allow the DTD to be customized by wrapper DTDs (external client DTDs that use or import the Docutils DTD). Parameter entities may be overridden by wrapper DTDs, replacing the definitions below with custom definitions. Parameter entities whose names begin with “additional” are meant to allow easy extension by wrapper DTDs.

%anonymous.att;

The %anonymous.att; parameter entity contains the anonymous attribute, used for unnamed hyperlinks.

Entity definition:

anonymous %yesorno; #IMPLIED

The reference and target elements directly employ the %anonymous.att; parameter entity in their attribute lists.

%auto.att;

The %auto.att; parameter entity contains the auto attribute, used to indicate an automatically-numbered footnote or title.

Entity definition:

auto     CDATA     #IMPLIED

The footnote, footnote_reference, and title elements directly employ the %auto.att; parameter entity in their attribute lists.

%backrefs.att;

The %backrefs.att; parameter entity contains the backrefs attribute, a space-separated list of id references, for backlinks.

Entity definition:

backrefs  IDREFS    #IMPLIED

The citation, footnote, and system_message elements directly employ the %backrefs.att; parameter entity in their attribute lists.

%basic.atts;

The %basic.atts; parameter entity lists attributes common to all Docutils elements. See Common Attributes.

Entity definition:

ids      NMTOKENS  #IMPLIED
names    CDATA     #IMPLIED
dupnames CDATA     #IMPLIED
source   CDATA     #IMPLIED
classes  NMTOKENS  #IMPLIED
%additional.basic.atts;

The %additional.basic.atts; parameter entity can be used by wrapper DTDs to extend %basic.atts;.

%bibliographic.elements;

The %bibliographic.elements; parameter entity contains an OR-list of all bibliographic elements.

Entity definition:

author | authors | organization | contact | address
| version | revision | status | date | copyright
| field
%additional.bibliographic.elements;

The %additional.bibliographic.elements; parameter entity can be used by wrapper DTDs to extend %bibliographic.elements;.

Only the docinfo element directly employs the %bibliographic.elements; parameter entity in its content model.

%body.elements;

The %body.elements; parameter entity contains an OR-list of all body elements. %body.elements; is itself contained within the %structure.model; parameter entity.

Entity definition:

admonition | attention | block_quote | bullet_list | caution
| citation | compound | comment | container | danger |
  definition_list | doctest_block | enumerated_list | error |
  field_list | figure | footnote | hint | image | important
  | line_block | literal_block | note | option_list |
  paragraph | pending | raw reference | rubric |
  substitution_definition | system_message | table | target |
  tip | warning %additional.body.elements;

The %additional.body.elements; parameter entity can be used by wrapper DTDs to extend %body.elements;.

The %body.elements; parameter entity is directly employed in the content models of the following elements: admonition, attention, block_quote, caution, citation, compound, danger, definition, description, entry, error, field_body, footer, footnote, header, hint, important, legend, list_item, note, sidebar, system_message, tip, topic, warning

Via %structure.model;, the %body.elements; parameter entity is indirectly employed in the content models of the document and section elements.

%fixedspace.att;

The %fixedspace.att; parameter entity contains the xml:space attribute, a standard XML attribute for whitespace-preserving elements.

Entity definition:

xml:space (default | preserve) #FIXED 'preserve'

The %fixedspace.att; parameter entity is directly employed in the attribute lists of the following elements: address, comment, doctest_block, line_block, literal_block, raw

%inline.elements;

The %inline.elements; parameter entity contains an OR-list of all inline elements.

Entity definition:

abbreviation | acronym | citation_reference | emphasis |
footnote_reference | generated | image | inline | literal |
problematic | raw | reference | strong | substitution_reference |
subscript | superscript | target | title_reference
%additional.inline.elements;

The %additional.inline.elements; parameter entity can be used by wrapper DTDs to extend %inline.elements;.

Via %text.model;, the %inline.elements; parameter entity is indirectly employed in the content models of the following elements: abbreviation, acronym, address, attribution, author, caption, classifier, contact, copyright, date, doctest_block, emphasis, generated, inline, line_block, literal_block, math, math_block, organization, paragraph, problematic, raw, reference, revision, rubric, status, strong, subscript, substitution_definition, substitution_reference, subtitle, superscript, target, term, title, title_reference, version

%reference.atts;

The %reference.atts; parameter entity groups together the refuri, refid, and refname attributes.

Entity definition:

%refuri.att;
%refid.att;
%refname.att;
%additional.reference.atts;

The %additional.reference.atts; parameter entity can be used by wrapper DTDs to extend %additional.reference.atts;.

The citation_reference, footnote_reference, reference, and target elements directly employ the %reference.att; parameter entity in their attribute lists.

%refid.att;

The %refid.att; parameter entity contains the refid attribute, an internal reference to the ids attribute of another element.

Entity definition:

refid   CDATA     #IMPLIED

The title and problematic elements directly employ the %refid.att; parameter entity in their attribute lists.

Via %reference.atts;, the %refid.att; parameter entity is indirectly employed in the attribute lists of the citation_reference, footnote_reference, reference, and target elements.

%refname.att;

The %refname.att; parameter entity contains the refname attribute, an internal reference to the names attribute of another element. On a target element, refname indicates an indirect target which may resolve to either an internal or external reference.

Entity definition:

refname  NMTOKENS  #IMPLIED

The substitution_reference element directly employs the %refname.att; parameter entity in its attribute list.

Via %reference.atts;, the %refname.att; parameter entity is indirectly employed in the attribute lists of the citation_reference, footnote_reference, reference, and target elements.

%refuri.att;

The %refuri.att; parameter entity contains the refuri attribute, an external reference to a URI/URL.

Entity definition:

refuri   CDATA     #IMPLIED

Via %reference.atts;, the %refuri.att; parameter entity is indirectly employed in the attribute lists of the citation_reference, footnote_reference, reference, and target elements.

%section.elements;

The %section.elements; parameter entity contains an OR-list of all section-equivalent elements. %section.elements; is itself contained within the %structure.model; parameter entity.

Entity definition:

section
%additional.section.elements;

The %additional.section.elements; parameter entity can be used by wrapper DTDs to extend %section.elements;.

Via %structure.model;, the %section.elements; parameter entity is indirectly employed in the content models of the document and section elements.

%structure.model;

The %structure.model; parameter entity encapsulates the hierarchical structure of a document and of its constituent parts. See the discussion of the element hierarchy above.

Entity definition:

( ( (%body.elements; | topic | sidebar)+, transition? )*,
  ( (%section.elements;), (transition?, (%section.elements;) )* )? )

Each document or section contains zero or more body elements, topics, and/or sidebars, optionally interspersed with single transitions, followed by zero or more sections (whose contents are recursively the same as this model) optionally interspersed with transitions.

The following restrictions are imposed by this model:

  • Transitions must be separated by other elements (body elements, sections, etc.). In other words, a transition may not be immediately adjacent to another transition.

  • A transition may not occur at the beginning of a document or section.

An additional restriction, which cannot be expressed in the language of DTDs, is imposed by software:

  • A transition may not occur at the end of a document or section.

The %structure.model; parameter entity is directly employed in the content models of the document and section elements.

%text.model;

The %text.model; parameter entity is used by many elements to represent text data mixed with inline elements.

Entity definition:

(#PCDATA | %inline.elements;)*

The %text.model; parameter entity is directly employed in the content models of the following elements: abbreviation, acronym, address, author, caption, classifier, contact, copyright, date, doctest_block, emphasis, field_name, generated, line_block, literal_block, organization, paragraph, problematic, raw, reference, revision, status, strong, substitution_definition, substitution_reference, subtitle, target, term, title, version