Attachment 'reStructuredText.html'
Download结构化文本(reStructuredText)测试文档
语法结构示例 Examples of Syntax Constructs
作者: | David Goodger |
---|---|
地址: | 123 Example Street Example, EX Canada A1B 2C3 |
联系: | [email protected] |
译者: | Me; |
组织: | infopro.cn |
日期: | 2004-01-04 |
状态: | 完善ing;This is a "work in progress" |
当前版本: | 1.29 |
版本: | 1 |
Copyright: | 此文档遵从开放原则,你可以自由的复制,修改,发布,发售,购买, 租借,销毁,改进;或是引用,摘录,合并,比较,分类等等 总之你可以自由使用此文档; This document has been placed in the public domain. You may do with it as you wish. You may copy, modify, redistribute, reattribute, sell, buy, rent, lease, destroy, or improve it, quote it at length, excerpt, incorporate, collate, fold, staple, or mutilate it, or do anything else to it that your or anyone else's heart desires. |
条目名称 field name: | |
普通文档信息栏 This is a generic bibliographic field. | |
条目名称2 field name 2: | |
普通文档信息栏可以包含其它元素 Generic bibliographic fields may contain multiple 文档元素 Body Elements. (但是条目名称不能使用中文,否则脚本不能生成正常排版格式) 比如说 Like this. |
Dedication
罗列捐献和开发者名录;For Docutils users & co-developers.
Abstract
这是一个测试文档,包含了 新结构化文本 的所有元素的例子 This is a test document, containing at least one example of each reStructuredText construct.
- 1 结构元素 Structural Elements
- 2 实际效果--第一级别
- 3 文档元素 Body Elements
- 3.1 段落 Paragraphs
- 3.2 标点列表 Bullet Lists
- 3.3 列举列表 Enumerated Lists
- 3.4 定义式列表 Definition Lists
- 3.5 字段列表 Field Lists
- 3.6 选项列表 Option Lists
- 3.7 原文块 Literal Blocks
- 3.8 引述块 Block Quotes
- 3.9 测试块 Doctest Blocks
- 3.10 表格 Tables
- 3.11 脚注 Footnotes
- 3.12 引用 Citations
- 3.13 标签Targets
- 3.14 指引Directives
- 3.15 替换定义 Substitution Definitions
- 3.16 注释 Comments
- 4 错误处理 Error Handling
1 结构元素 Structural Elements
章节层次,是通过使用不同的行装饰字串实现的,实际上你可以使用任何字串, 在章节标题行下,使用 行装饰字串 再另起一行就好(注意,行装饰字串至少要与标题一样长)
推荐使用如下 行装饰字串:
第一级 ============== 第二级 -------------- 第三级 `````````````` 第四级 '''''''''''''' 第五级 """"""""""""""
即,按照键盘的左右顺序 选的几个不常用字符,实际上 结构文本支持更深层次的结构, 但是HTML标签只支持到 H6,且,不建议创立过多层次的文档...
2 实际效果--第一级别
文章序言
2.2 章节标题 Section Title
就是在 行装饰字串 上面一行的文字 That's it, the text just above this line.
3 文档元素 Body Elements
3.1 段落 Paragraphs
一个自然段 A paragraph.
3.1.1 行内标记Inline Markup
段落文字可以包含一些行内标记: 强调, 加重强调 , 斜体,
标准超链接(http://www.python.org), 扩展超链接 (Python 5),
内联交叉参考(example), 扩展超链接内嵌URIs (Python网站),
脚注参考引用 (使用数字 1, 末名自动数字 3, 使用标签 2, 或是符号 *),
参考引用([CIT2002]),
置换引用 ()<-- 图片,
以及 行内超链接标签 (参看后文的 标签Targets 部分).
字符级 行内标记Inline Markup 也支持(即使非常的丑!) 在 新结构化文本 reStructuredText 都是可能的. (注意 修饰符前要有空格)
解析时的问题将使用 |problematic| 指出 (此处故意产生一个错误 generated by processing errors; this one is intentional).
默认的解析规则字符是 标题参考. 这儿有几种显式的规则字符:
PEP参考 (PEP 287);
RFC参考 (RFC 2822);
下标 subscript;
上标 superscript;
以及扩展规则 标准强调 行内加重 标记强调.
即通过:
:特殊规则字符:`正常字串`
以上形式的 规则字符 前导,改变解析输出!
让我们来进行一次行内空白与包绕试验:(对中文支持应该不严密) Let's test wrapping and whitespace significance in inline literals: This is an example of --inline-literal --text, --including some-- strangely--hyphenated-words. Adjust-the-width-of-your-browser-window to see how the text is wrapped. -- ---- -------- Now note the spacing between the words of this sentence (words should be grouped in pairs).
如果 --pep-references 选项已经支持,则此链接应该已经存在 PEP 258
3.2 标点列表 Bullet Lists
标点列表 A bullet list
- 嵌套标点列表 Nested bullet list.
- 嵌套标点列表项 2 Nested item 2.
列表项 2 Item 2.
列表项 2 的内容段落 Paragraph 2 of item 2.
- 嵌套标点列表 Nested bullet list.
- 嵌套标点列表项 2 Nested item 2.
- 第三级 Third level.
- 列表项 2 Item 2.
- 嵌套标点列表项 3 Nested item 3.
3.3 列举列表 Enumerated Lists
阿拉伯数字式 Arabic numerals.
- 小写字母lower alpha)
- (小写罗马lower roman)
- 大写字母upper alpha.
- 大写罗马upper roman)
- 大写字母upper alpha.
- (小写罗马lower roman)
- 小写字母lower alpha)
列表不从 1 开始 Lists that don't start at 1:
- Three
- Four
- C
- D
- iii
- iv
3.4 定义式列表 Definition Lists
- Term
- Definition
- Term : classifier
Definition paragraph 1.
Definition paragraph 2.
- Term
- Definition
3.5 字段列表 Field Lists
怎样what: | 字段列表是一组字段名对应字段体,就象数据库的记录, 常常作为扩展语法的一部分,精确的叙述在: RFC 2822 Field lists map field names to field bodies, like database records. They are often part of an extension syntax. They are an unambiguous variant of :RFC: 2822 fields. |
---|---|
多个参数how arg1 arg2: | |
字段标记是 冒号 字段名 冒号 The field marker is a colon, the field name, and a colon. 字段体可以包含其它文档元素 The field body may contain one or more Body Elements, indented relative to the field marker. |
3.6 选项列表 Option Lists
用以说明命令行选项 For listing command-line options:
-a | 命令行选项 "a" |
-b file | 选项可以带参数 和长的说明 |
--long | 选项也可以完整型 |
--input=file | 完整型选项也可带参数 |
--very-long-option | |
说明也可以另起一行 说明也可以包含其它文档元素 不用理会从何处开始 | |
-x, -y, -z | 多个选项成为一 "选项组". |
-v, --verbose | 比照: 缩简式 & 完整式. |
-1 file, --one=file, --two file | |
多个选项加参数. | |
/V | DOS/VMS 形式的选项也可以 |
在选项与描述中至少有两个空格
3.7 原文块 Literal Blocks
原文块 Literal blocks 由两个冒号指出 ("::") 另一空白行结束. 原文块一般用以忠实的复述有严格缩进的程序代码:
if literal_block: text = 'is left as-is' spaces_and_linebreaks = 'are preserved' markup_processing = None
也可能引用没有缩排的:
>> Great idea! > > Why didn't I think of that?
3.8 引述块 Block Quotes
由缩进的文档元素组成:
My theory by A. Elk. Brackets Miss, brackets. This theory goes as follows and begins now. All brontosauruses are thin at one end, much much thicker in the middle and then thin again at the far end. That is my theory, it is mine, and belongs to me and I own it, and what it is too.
—Anne Elk (Miss)
3.9 测试块 Doctest Blocks
>>> print 'Python格式使用实例由 ">>>" 开始' Python-specific usage examples; begun with ">>>" >>> print '(cut and pasted from interactive Python sessions)' (cut and pasted from interactive Python sessions)
3.10 表格 Tables
下面是栅格式表格接着是简单式表格:
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 | Cells may span columns. | ||
body row 3 | Cells may span rows. |
|
|
body row 4 | |||
body row 5 | Cells may also be empty: --> |
Inputs | Output | |
---|---|---|
A | B | A or B |
False | False | False |
True | False | True |
False | True | True |
True | True | True |
3.11 脚注 Footnotes
[1] | (1, 2) 每一脚注都可以包含其它文档元素, 不过注意要统一有至少三空格以上的缩进 此为脚注的第二段 This is the footnote's second paragraph. |
[2] | (1, 2) 脚注可能是数字式的, 手工指定(如 1) 或是自动分配 使用标签前加 "#". 此条脚注有一标签使它可以在其它多处被引用, 以脚注参考的形式 (2) 或是超链接引用 (label). |
[3] | 此为自动分配数字式引用的脚注,拥有匿名的标签引用标签 仅使用 "#" . |
[*] | 脚注也可使用符号, 特别的使用 "*" 标签. 引用下一脚注: †. |
[†] | 这是符号式脚注序列中的另一条目 |
[4] | 这是未引用过的脚注,连同一个不存在的脚注的引用: 4. |
3.12 引用 Citations
[CIT2002] | (1, 2) 引用,是文字标签的脚注. 比一般脚注表现的不同. |
就是对上面的引用, [CIT2002], 以及一个 [不存在nonexistent]_ 的引用.(故意引发一个错误报告)
3.13 标签Targets
此段落由显示声明的" example "标签所指(由注释中的标签声明构成)
以下还可以看到 前面的 行内标记Inline Markup 引用, 行内超链接标签 也支持
章节的标头是隐含的 标签,由名称来引用,
比如说: 标签Targets , 这是另一节的标题引用 文档元素 Body Elements.
标签也可以以匿名或是间接命名方式来引用!
这则是 `没有定义标签的超链接 hyperlink reference without a target`_, 这将引发一个错误
直接外部链接声明: 《计算机行业 术语对照表(英日中)》 6
注意: | 对于外部链接,可以通过"__ " 前导,直接声明到对应字串上; 但是使用".. _标签:URL"的方式,更加灵活,因为可以通过使用 "标签_" 的形式,在多处进行引用! (此处的引用因为没有进行过定义,所以会产生报错) |
---|
3.13.2 重复的标签名
现在有两个 "重复的标签名" 小节, 系统不能通过名称来正确引用他们, 若尝试如此引用:( `重复的标签名`_), 将产生一个报错.
3.14 指引Directives
一个简单的一些 结构文本 结构指引的例子
其它的情况请参考 http://docutils.sf.net/spec/rst/directives.html.
3.14.1 文档部分 Document Parts
上面为本章节的"内容"指引示例 (一个本地的无标题的内容指引表 Contents)
在文档开始(一个全文档范围的 内容索引 Table of Contents).
3.14.2 图片 Images
以下是图像指引 (可点击,含一超链接引用 -- ):
以下是 指向引用:
指向(figure)是可以拥有标题和解说的图片:
re | Revised, revisited, based on 're' module. |
Structured | Structure-enhanced text, structuredtext. |
Text | Well it is, isn't it? |
本段落依然属于图片的解说, This paragraph is also part of the legend.
3.14.3 警告 Admonitions
Attention!
注意!
Directives at large.(也可以含有其它结构文档元素)
Caution!
警告!
Don't take any wooden nickels.
!DANGER!
危险!
Mad scientist at work!
Error
错误……
Does not compute.
Hint
暗示……It's bigger than a bread box.Important
重要! - Wash behind your ears. - Clean up your room. - Call your mother. - Back up your data.Note
解说……
This is a note.
Tip
小贴士……
15% if the service is good.
Warning
警报……
Strong prose may provoke extreme mental exertion. Reader discretion is strongly advised.
注意!
And, by the way...
You can make up your own admonition too.
3.14.4 主题,边注和加红 Topics, Sidebars, and Rubrics
主题标题 Topic Title
这是一个主题 This is a topic.
这是加红效果 This is a rubric
3.14.5 脚注标签 Target Footnotes
[5] | (1, 2, 3) http://www.python.org/ |
[6] | http://192.168.2.29:7080/moin/KatakanaTEtab |
使用"target-notes: :" 标签,会自动在脚注位置整理输出所有外部链接信息
3.14.6 行文本块 Line Blocks
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...
4 错误处理 Error Handling
任何处理时捕获的错误都会生成系统信息. Any errors caught during processing will generate system messages.
测试文本将生成5条报错信息,并自动生成 "Docutils System Messages"章节:
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.