restructuredText样式(一级标题)

章节标题(二级标题)

三级标题

四级标题

五级标题
六级标题

段落

段落由空白行分割,左侧必须对齐(没有空格,或者有相同多的空格)。缩进的段落意味着引用。 例如

这是第一段

这是第二段 这还是第二段

行内标记

斜体

加粗

强调解释

行内代码

A下标xxx A xxx A上标xxx A xxx

注意:

对于行内标记, 标记前后要留有至少一个空格. 如 你好*我没变斜*你好 –> 你好*我没变斜*你好, 正确为: 你好 我变斜了 你好 –> 你好 我变斜了 你好, 或 你好 我变斜了 你好 –> 你好我变斜了你好.

列表

无序列表使用 - , * , + 来标记:

  • 无序列表第一项

  • 无序列表第二项

有序列表使用 num. 来标记:

  1. 有序列表第一项

  2. 有序列表第二项

自动编号列表必须使用 #. 来标记:

  1. 自动编号的列表第一项

  2. 自动编号的列表第二项

这是一个定义列表:

term

术语定义必须缩进

可以包含多个段落

next term

术语描述

下面是一个嵌套列表, 每一级别向右缩进一次, 同级别缩进应相同:

  1. 有序列表第一项
    • 无序列表第一项

    • 无序列表第二项

  2. 有序列表第二项
    • 无序列表第一项

    • 无序列表第二项

表格

网格表(带表标题和编号)

网格表中使用的符号有:-、=、 |、+。 - 用来分隔行, = 用来分隔表头和表体行,| 用来分隔列,+ 用来表示行和列相交的节点。

以下代码段指定四列的相对宽度,更改每列的文本对齐方式,禁用第三、四列的文本换行:

Grid Table Demo

Header row, column 1 (header rows optional)

Header 2

Header 3

Header 4

body row 1, column 1

column 2

column 3

column 4

body row 2

...

...

可以使用 Grid Table Demo 引用, 在Sphinx中还可以使用 table-gridtable 来引用.

简单表格(无表标题和编号)

书写简单, 但有一些限制: 需要有多行, 且第一列元素不能分行显示, 如下

A

B

A and B

False

False

False

True

False

False

False

True

False

True

True

True

CSV表格(带表标题和编号)

Frozen Delights!

Treat

Quantity

Description

Albatross

2.99

On a stick!

Crunchy Frog

1.49

If we took the bones out, it wouldn't be crunchy, now would it?

Gannet Ripple

1.99

On a stick!

list table(带表标题和编号)

List tables can have captions like this one.

List table

Header 1

Header 2

Header 3 long. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sit amet mauris arcu.

Stub Row 1

Row 1

Column 2

Column 3 long. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sit amet mauris arcu.

Stub Row 2

Row 2

Column 2

Column 3 long. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sit amet mauris arcu.

Stub Row 3

Row 3

Column 2

Column 3 long. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sit amet mauris arcu.

sublime text

使用”Restructured Text (RST) Snippets”, 即 sublime-rst-completion , 表格的制作将变得极为简单。详见sublime.txt

注释

你可以看到我, 我不是注释.

图片

image指令图片

无发自动生成编号,不建议使用,后续会将手册中所有image指令图片替换为figure指令图片

对于不能显示图片的时候, 显示这些文字

figure指令图片(包含图片标题、编号和图例)

map to buried treasure

This is the caption of the figure (a simple paragraph).

The legend consists of all elements after the caption. In this case, the legend consists of this paragraph

代码块

some codes1
some codes1

指令

提示

This is a tip

注意

This is a note

Hint

This is a hint

Danger

This is a danger

Error

This is an error

警告

This is a warning

Caution

This is a caution

Attention

This is an attention

Important

This is an important

另请参阅

This is seealso

Usage

Simple snippets work as tab-triggered shortcuts: type the shortcut and press <TAB> to replace it with the snippet. If the snippet has placeholders, you can jump between them using tab.

shortcut

result

key binding

h1

Header level 1

see Headers

h2

Header level 2

h3

Header level 3

e

emphasis

ctrl+alt+i ( super+shift+i on Mac)

se

strong emphasis (bold)

ctrl+alt+b ( super+shift+b on Mac)

lit or literal

literal text (inline code)

ctrl+alt+k ( super+shift+k on Mac)

list

unordered list

see Smart Lists

listn

ordered list

listan

auto ordered list

def

term definition

code

code-block directive (sphinx)

source

preformatted ( :: block)

img

image

fig

figure

table

simple table

ctrl+t see Magic Tables

link

refered hyperlink

linki

embeded hyperlink

fn or cite

autonumbered footnote or cite

alt+shift+f see Magic 脚注

quote

Quotation ( epigraph directive)

Also standard admonitions are expanded:

shortcut

attention

caution

danger

error

hint

important

note

tip

warning

Render preview

You can preview your document in different formats converted with different tools pressing ctrl+shift+r .

The Quick Window will offer the format and tool and the result will be automatically open after the conversion.

By the moment, it can use Pandoc_ , rst2pdf_ , or rst2*.py tools (included with docutils_ ) to produce html , pdf , odt or docx output formats.

Each time you select a format + tool option, it turns the default the following times.

注意

The original code is from the SublimePandoc project.

Magic Tables

There is a particular magic expansion for tables. Here is how it works:

网格表

  1. 创建表格提纲, 用一个或多个空格分割列:

    This is paragraph text *before* the table.
    
    Column 1  Column 2
    Foo  Put two (or more) spaces as a field separator.
    Bar  Even very very long lines like these are fine, as long as you do not put in line endings here.
    
    This is paragraph text *after* the table.
    
  2. 把鼠标放在要转化成表格的内容里.

  3. 按下 ctrl+t, enter (Linux or Windows) or super+shift+t, enter (Mac). 将会自动格式化成表格:

    This is paragraph text *before* the table.
    
    +----------+---------------------------------------------------------+
    | Column 1 | Column 2                                                |
    +==========+=========================================================+
    | Foo      | Put two (or more) spaces as a field separator.          |
    +----------+---------------------------------------------------------+
    | Bar      | Even very very long lines like these are fine, as long  |
    |          | as you do not put in line endings here.                 |
    +----------+---------------------------------------------------------+
    
    This is paragraph text *after* the table.
    

现在假设你想增加某一单元格内容:

+----------+---------------------------------------------------------+
| Column 1 | Column 2                                                |
+==========+=========================================================+
| Foo is longer now     | Put two (or more) spaces as a field separator.          |
+----------+---------------------------------------------------------+
| Bar      | Even very very long lines like these are fine, as long  |
|          | as you do not put in line endings here.                 |
+----------+---------------------------------------------------------+

按下同样的快捷键, 表格结构会自动调整:

+-------------------+--------------------------------------------------------+
| Column 1          | Column 2                                               |
+===================+========================================================+
| Foo is longer now | Put two (or more) spaces as a field separator.         |
+-------------------+--------------------------------------------------------+
| Bar               | Even very very long lines like these are fine, as long |
|                   | as you do not put in line endings here.                |
+-------------------+--------------------------------------------------------+

此外,如果你想保持列宽固定,可以按``ctrl+t, r`` or super+shift+t, r (Mac):

+----------+---------------------------------------------------------+
| Column 1 | Column 2                                                |
+==========+=========================================================+
| Foo is   | Put two (or more) spaces as a field separator.          |
| longer   |                                                         |
| now      |                                                         |
+----------+---------------------------------------------------------+
| Bar      | Even very very long lines like these are fine, as long  |
|          | as you do not put in line endings here.                 |
+----------+---------------------------------------------------------+

还可以使用鼠标合并单元格:

+----+----+
| h1 | h2 |
+====+====+
| 11 | 12 |
+----+----+
| 21 | 22 |
+----+----+

移动鼠标到单元格 12 ,按 ctrl+t, down 。 将得到:

+----+----+
| h1 | h2 |
+====+====+
| 11 | 12 |
+----+    |
| 21 | 22 |
+----+----+

注意

The original code of this feature was taken from Vincent Driessen's vim-rst-tables :

注意

The original code of wcwidth was taken to solve alignment issue with CJK characters.

简单表格

  1. 创建表格提纲, 用一个或多个空格分割列:

    This is paragraph text *before* the table.
    
    Column 1  Column 2
    Foo Put two (or more) spaces as a field separator.
    Bar  Even very very long lines like these are fine, as long as you do not put in line endings here.
    
    This is paragraph text *after* the table.
    
  2. 把光标放在要转化成表格的内容里.

  3. 按下 ctrl+t, s (Linux or Windows) or super+shift+t, s (Mac). 将会自动格式化成表格:

    This is paragraph text *before* the table.
    
    ==========  ================================================================================================
    Column 1    Column 2
    ==========  ================================================================================================
    Foo         Put two (or more) spaces as a field separator.
    Bar         Even very very long lines like these are fine, as long as you do not put in line endings here.
    ==========  ================================================================================================
    
    This is paragraph text *after* the table.
    

现在假设你想增加某一单元格内容:

==========  ================================================================================================
Column 1    Column 2
==========  ================================================================================================
Foo is longer now         Put two (or more) spaces as a field separator.
Bar         Even very very long lines like these are fine, as long as you do not put in line endings here.
==========  ================================================================================================

按下同样的快捷键, 表格结构会自动调整:

===================  ================================================================================================
Column 1             Column 2
===================  ================================================================================================
Foo is longer now    Put two (or more) spaces as a field separator.
Bar                  Even very very long lines like these are fine, as long as you do not put in line endings here.
===================  ================================================================================================

注意

The original code of this feature was taken from Vincent Driessen's vim-rst-tables :

Smart lists

Ordered or unordered lists patterns are automatically detected. When you type something like this:

1. Some item
2. Another|

When press enter the newline will prepended with a logical next item:

...
2. Another
3. |

If you press enter when the item is empty, the markup is erased keeping the same indent as the previous line, in order to allow multilines items. Also note that orderer list works with an alphabetic pattern or roman numbers pattern suffixed with a period ( a. b. c. ... , A. B. C. ... , i. ii. iii. iv. ... , X. XI. XII. ... , #. ); surrounded by parentheses ( (a) (b) (c) ... , (A) (B) (C) ... , (i) (ii) (iii) (iv) ... , (X) (XI) (XII) ... , (#) ); or suffixed with a right-parenthesis. ( a) b) c) ... , A) B) C) ... , i) ii) iii) iv) ... , X) XI) XII) ... , #) );

提示

The very same feature works for line blocks starting a line with | .

注意

This feature was proudly stolen from Muchenxuan Tongh's SmartMarkdown

Headers

Autocompletion

You can autocomplete standard headers (over/)underlines with TAB .

For example try this:

**********<TAB>
A longer main title
*******

Or this:

A subtitle
---<TAB>

You'll get:

*******************
A longer main title
*******************

A subtitle
----------

respectively.

Folding/unfolding

If you put the cursor in a completed header and press shift + TAB ( alt + TAB in Mac), the section under it will be folded/unfolded.

For example:

Folding/unfolding
+++++++++++++++++<TAB>

If you put the cursor in a completed header and press ``shift + TAB``,
(``alt + TAB`` in Mac) the section under it will be folded/unfolded.

Navigation
++++++++++

...

Result in:

https://raw.github.com/dbousamra/sublime-rst-completion/11_foldable_headers/img/folding.png

Nested sections under a header are included.

Also, it's possible to jump between headers. alt+down and alt+up move the cursor position to the closer next or previous header respectively.

alt+shift+down and alt+shift+up to the same, but only between headers with the same or higher level (i.e. ignore childrens)

The header level is detected automatically.

Adjust header level

With the cursor in a header, press ctrl + + (plus key) and ctrl + - (minus key) ( alt + + and alt + - , in Mac) will increase and decrease the header level respectively. The adornment decoration (underline / overline) are autodetected from the document and uses Sphinx's conventions as default.

For example, you have the cursor in:

Magic 脚注|
---------------

Which is a header level 2 and want to convert to a level 3, press ctrl + - to get:

Magic 脚注
+++++++++++++++
|

Magic 脚注

This is the smarter way to add footnotes, grouping them (and keepping count) in a common region at the bottom of the document.

When you want to add a new note, press alt+shift+f . This will happen:

  • A new n+1 (where n is the current footnotes count) note reference will be added in the current cursor position

  • The corresponding reference definition will be added at the bottom of the footnotes region

  • The cursor will be moved to write the note

After write the note you can go back to the reference with shift+up . Also, if the cursor is just after a reference (i.e: the caret is next to the underscore like this [XX]_| ) you can jump to its definition with shift+down .

This feature is based on the code by J. Nicholas Geist for MarkdownEditing

链接

外部链接

(外部网页,或不同的rst文件) 1

  1. 更多信息参考`引用文档 < http://example.com/ >`_

  2. 更多信息参考 引用文档 .

  1. 如果链接文本是Web地址,reStructuredText会自动将网址生成超链接。 https://github.com/SeayXu/

sublime更多信息参考 sublime text

内部链接

(需要使用 .. _label: )

  1. 如果想对图片或者表格加个链接:

上方 图片 处放置了一个标签 figure-logo , 注意空白行。

通过 This is the caption of the figure (a simple paragraph). 引用, 点击会跳到图像位置

  1. 对标题添加链接:

正文正文正文正文正文正文正文正文正文正文

通过 my-reference-label 引用, 点击会跳到 “设置一个标题链接” 位置

  1. 对其余内容添加标签,使用 Link Title , Link Title为链接指定明确的标题

  1. 在同一个rst中,小节标题会自动生成超链接地址,使用小节标题作为超链接名称就可以生成隐式链接。例如: 行内标记信息参考 行内标记

脚注

包含两步: 1. 在文档底部放置脚注主体, 以 rubric 指令标示:

2. 在需要插入脚注的地方插入脚注名 [#name] 其中, 使用 2 可以实现自动编号, 当然也可以使用数字来指示确定的脚注编号 3 .

替换引用

替换引用就是用定义的指令替换对应的文字或图片 这是 logo kingbase的Logo,我的kingbase用户名是:xxx。

脚注

1

第1条脚注的文本.

2

第2条脚注的文本.

3

第3条脚注的文本.