http://docutils.sourceforge.net/docs/rst/quickref.html
Being a cheat-sheet for reStructuredText
Updated 2003-06-10
Copyright: This document has been placed in the public domain.
マークアップの完全な詳細はreStructuredTextページにあります。このドキュメントは心覚えとして意図しているだけです。
"(details)"のようなリンクは完全なreStructuredText specificationドキュメントのHTMLバージョンの中を指しています。これらは相対リンクです。つながらない場合は、master "Quick reStructuredText"ドキュメントを使ってください。
(詳細)
インラインマークアップはテキスト内部の語と句が(イタリック体とボールド体のような)字体と(ハイパーリンクのような)機能を持てるようにします。
| 平文 | 典型的な結果 | 注釈 |
|---|---|---|
| *emphasis* | emphasis | 通常イタリック体にされます。 |
| **strong emphasis** | strong emphasis | 通常ボールド体にされます。 |
| `interpreted text` | (右の注釈を参照) | 解釈されたテキストのレンダリングと意味は範囲もしくは用途に依存します。インデックスのエントリや(プログラム識別子のような)説明的マークアップのようなものに使うことができます。 |
| ``inline literal`` | inline literal
| 通常固定スペーステキストにされます。スペースは維持されるはずですが、改行はそうではないでしょう。 |
| reference_ | reference | 単純な一語ハイパーリンク参照。ハイパーリンクを参照してください。 |
| `phrase reference`_ | phrase reference | 空白または句読点をもつハイパーリンク参照はバッククオートで引用される必要があります。ハイパーリンクを参照してください。 |
| anonymous__ | anonymous | 一つではなく二つの下線を使い、単純参照と句参照の両方を無名にすることができます(参照テキストの参照先は重複しません)。ハイパーリンクを参照してください。 |
| _`inline internal target` | inline internal target | テキスト内部の相互参照。ハイパーリンクを参照してください。 |
| |substitution reference| | (右の注釈を参照) | 置換定義から結果を置き換えます。それはテキスト、画像、ハイパーリンク、あるいは、これらと他のものの組み合わせであってもよい。 |
| footnote reference [1]_ | footnote reference 1 | 脚注を参照してください。 |
| citation reference [CIT2002]_ | citation reference [CIT2002] | 引用を参照してください。 |
| http://docutils.sf.net/ | http://docutils.sf.net/ | スタンドアロンのハイパーリンク。 |
アスタリスク、バッククオート、垂直バーおよび下線はインラインの区切り文字です。アスタリスク、バッククオートおよび垂直バーはクオート記号のように振る舞います。マークアップされた語や句を取り巻く文字にマッチングし、空白や他のクオートが外側に必要です。そして、空白がその内部に存在することはできません。インラインの区切り文字をその文字のまま使いたい場合は、バックスラッシュでエスケープするか、もしくはバッククオートでそれらをクオートする、すなわちインラインリテラルを使用してください。
詳しく説明すると、reStructuredText仕様書によれば、インラインマークアップの中では以下のルールが開始文字列と終了文字列(インラインマークアップ区切り文字)に適用する:
インラインマークアップは入れ子にできないかもしれないことも覚えておいてください(ただし、インラインリテラルはその他のインラインマークアップ区切り文字のどれかを含むことができることは除きます。しかし、それは重要でありません。なぜなら、何も処理されないからです)。
(詳細)
reStructuredTextはマークアップ文字に与えられた特別な意味を上書きしてリテラル文字自身を得るためにバックスラッシュ("\")を使います。リテラルのバックスラッシュを得るためには、エスケープされたバックスラッシュ("\\")を仕様してください。例えば:
| Raw reStructuredText | Typical result |
|---|---|
| *escape* ``with`` "\" | escape with "" |
| \*escape* \``with`` "\\" | *escape* ``with`` "\" |
In Python strings it will, of course, be necessary to escape any backslash characters so that they actually reach reStructuredText. The simplest way to do this is to use raw strings:
| Python string | Typical result |
|---|---|
| r"""\*escape* \`with` "\\"""" | *escape* `with` "\" |
| """\\*escape* \\`with` "\\\\"""" | *escape* `with` "\" |
| """\*escape* \`with` "\\"""" | escape with "" |
(details)
| Plain text | Typical result |
|---|---|
|
=====
Title ===== Subtitle -------- Titles are underlined (or over- and underlined) with a printing nonalphanumeric 7-bit ASCII character. Recommended choices are "``= - ` : ' " ~ ^ _ * + # < >``". The underline/overline must be at least as long as the title text. |
Title
Subtitle Titles are underlined (or over- and underlined) with a printing nonalphanumeric 7-bit ASCII character. Recommended choices are "= - ` : ' " ~ ^ _ * + # < >". The underline/overline must be at least as long as the title text. |
(details)
| Plain text | Typical result |
|---|---|
|
This is a paragraph. Paragraphs line up at their left
|
This is a paragraph. Paragraphs line up at their left edges, and are normally separated by blank lines. |
(details)
| Plain text | Typical result |
|---|---|
|
Bullet lists:
- This is item 1
- Bullets are "-", "*" or "+".
Note that a blank line is required
| Bullet lists:
Note that a blank line is required before the first item and after the last, but is optional between items. |
(details)
| Plain text | Typical result |
|---|---|
|
Enumerated lists:
3. This is the first item
| Enumerated lists:
|
(details)
| Plain text | Typical result |
|---|---|
|
Definition lists:
what Definition lists associate a term with a definition. how The term is a one-line phrase, and the definition is one or more paragraphs or body elements, indented relative to the term. Blank lines are not allowed between term and definition. | Definition lists:
|
(details)
| Plain text | Typical result | ||||||||
|---|---|---|---|---|---|---|---|---|---|
|
:Authors:
Tony J. (Tibs) Ibbs, David Goodger (and sundry other good-natured folks) :Version: 1.0 of 2001/08/08
|
|
Field lists are used as part of an extension syntax, such as options for directives, or database-like records meant for further processing. Field lists may also be used as generic two-column table constructs in documents.
(details)
| Plain text | Typical result | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
-a command-line option "a"
|
|
There must be at least two spaces between the option and the description.
(details)
| Plain text | Typical result |
|---|---|
|
A paragraph containing only two colons
indicates that the following indented text is a literal block. :: Whitespace, newlines, blank lines, and all kinds of markup (like *this* or \this) is preserved by literal blocks. The paragraph containing only '::' will be omitted from the result. The ``::`` may be tacked onto the very end of any paragraph. The ``::`` will be omitted if it is preceded by whitespace. The ``::`` will be converted to a single colon if preceded by text, like this:: It's very convenient to use this form. Literal blocks end when text returns to the preceding paragraph's indentation. This means that something like:: We start here and continue here and end here. is possible. |
A paragraph containing only two colons indicates that the following indented text is a literal block. Whitespace, newlines, blank lines, and all kinds of markup (like *this* or \this) is preserved by literal blocks. The paragraph containing only '::' will be omitted from the result. The :: may be tacked onto the very end of any paragraph. The :: will be omitted if it is preceded by whitespace. The :: will be converted to a single colon if preceded by text, like this: It's very convenient to use this form. Literal blocks end when text returns to the preceding paragraph's indentation. This means that something like:
We start here
and continue here
and end here.
is possible. |
(details)
| Plain text | Typical result |
|---|---|
|
Block quotes are just:
Indented paragraphs, and they may nest. |
Block quotes are just:
|
(details)
| Plain text | Typical result |
|---|---|
|
Doctest blocks are interactive
>>> print "This is a doctest block."
|
Doctest blocks are interactive Python sessions. They begin with ">>>" and end with a blank line. >>> print "This is a doctest block."
|
"The doctest module searches a module's docstrings for text that looks like an interactive Python session, then executes all such sessions to verify they still work exactly as shown." (From the doctest docs.)
(details)
There are two syntaxes for tables in reStructuredText. Grid tables are complete but cumbersome to create. Simple tables are easy to create but limited (no row spans, etc.).
| Plain text | Typical result | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Grid table: +------------+------------+-----------+
|
Grid table:
| ||||||||||||||||||
|
Simple table: ===== ===== ======
|
Simple table:
| ||||||||||||||||||
(details)
| Plain text | Typical result |
|---|---|
|
A transition marker is a horizontal line
------------ A transition should not begin or end a
|
A transition marker is a horizontal line of 4 or more repeated punctuation characters. A transition should not begin or end a section or document, nor should two transitions be immediately adjacent. |
Transitions are commonly seen in novels and short fiction, as a gap spanning one or more lines, marking text divisions or signaling changes in subject, time, point of view, or emphasis.
Explicit markup blocks are used for constructs which float (footnotes), have no direct paper-document representation (hyperlink targets, comments), or require specialized processing (directives). They all begin with two periods and whitespace, the "explicit markup start".
(details)
| Plain text | Typical result | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
Footnote references, like [5]_.
Note that footnotes may get rearranged, e.g., to the bottom of the "page". .. [5] A numerical footnote. Note
|
Footnote references, like 5.
Note that footnotes may get rearranged, e.g., to the bottom of
the "page".
| ||||||||||
|
Autonumbered footnotes are
possible, like using [#]_ and [#]_. .. [#] This is the first one.
They may be assigned 'autonumber
.. [#third] a.k.a. third_ .. [#fourth] a.k.a. fourth_ |
Autonumbered footnotes are possible, like using 1 and 2.
They may be assigned 'autonumber labels' - for instance, 4 and 3.
| ||||||||||
|
Auto-symbol footnotes are also
possible, like this: [*]_ and [*]_. .. [*] This is the first one.
|
Auto-symbol footnotes are also
possible, like this: *
and †.
| ||||||||||
The numbering of auto-numbered footnotes is determined by the order of the footnotes, not of the references. For auto-numbered footnote references without autonumber labels ("[#]_"), the references and footnotes must be in the same relative order. Similarly for auto-symbol footnotes ("[*]_").
(details)
| Plain text | Typical result | ||||||
|---|---|---|---|---|---|---|---|
|
Citation references, like [CIT2002]_.
Note that citations may get rearranged, e.g., to the bottom of the "page". .. [CIT2002] A citation
Citation labels contain alphanumerics,
Given a citation like [this]_, one
.. [this] here. |
Citation references, like [CIT2002].
Note that citations may get rearranged, e.g., to the bottom of
the "page".
Citation labels contain alphanumerics, underlines, hyphens and fullstops. Case is not significant. Given a citation like [this], one can also refer to it like this.
| ||||||
(details)
| Plain text | Typical result | ||||||||
|---|---|---|---|---|---|---|---|---|---|
|
External hyperlinks, like Python_.
.. _Python: http://www.python.org/ |
| ||||||||
"Fold-in" is the representation typically used in HTML documents (think of the indirect hyperlink being "folded in" like ingredients into a cake), and "call-out" is more suitable for printed documents, where the link needs to be presented explicitly, for example as a footnote.
| Plain text | Typical result | ||||
|---|---|---|---|---|---|
| Internal crossreferences, like example_.
.. _example: This is an example crossreference target. |
|
(details)
| Plain text | Typical result |
|---|---|
|
Python_ is `my favourite
programming language`__. .. _Python: http://www.python.org/ __ Python_ |
The second hyperlink target (the line beginning with "__") is both an indirect hyperlink target (indirectly pointing at the Python website via the "Python_" reference) and an anonymous hyperlink target. In the text, a double-underscore suffix is used to indicate an anonymous hyperlink reference. In an anonymous hyperlink target, the reference text is not repeated. This is useful for references with long text or throw-away references, but the target should be kept close to the reference to prevent them going out of sync.
(details)
Section titles, footnotes, and citations automatically generate hyperlink targets (the title text or footnote/citation label is used as the hyperlink name).
| Plain text | Typical result |
|---|---|
|
Titles are targets, too
======================= Implict references, like `Titles are targets, too`_. |
Titles are targets, too
Implict references, like Titles are targets, too. |
(details)
Directives are a general-purpose extension mechanism, a way of adding support for new constructs without adding new syntax. For a description of all standard directives, see reStructuredText Directives.
| Plain text | Typical result |
|---|---|
| For instance:
.. image:: images/ball1.gif |
For instance:
|
(details)
Substitutions are like inline directives, allowing graphics and arbitrary constructs within text.
| Plain text | Typical result |
|---|---|
|
The |biohazard| symbol must be
used on containers used to
dispose of medical waste.
.. |biohazard| image:: biohazard.png |
The |
(details)
Any text which begins with an explicit markup start but doesn't use the syntax of any of the constructs above, is a comment.
| Plain text | Typical result |
|---|---|
| .. This text will not be shown
(but, for instance, in HTML might be rendered as an HTML comment) | |
|
An empty "comment" does not
"consume" following blocks. .. So this block is not "lost",
|
An empty "comment" does not
"consume" following blocks.
So this block is not "lost", despite its indentation. |
Users who have questions or need assistance with Docutils or reStructuredText should post a message to the Docutils-Users mailing list. The Docutils project web site has more information.
Authors: Tibs (tibs@tibsnjoan.co.uk) and David Goodger (goodger@users.sourceforge.net)