32

reStructuredText语法简单说明

 5 years ago
source link: http://www.cnblogs.com/MikeZhang/p/reStructuredText20180905.html?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

reStructuredText 是扩展名为.rst的纯文本文件,含义为"重新构建的文本"",也被简称为:RST或reST。

官方网址:

http://docutils.sourceforge.net/rst.html

rst用户手册:

http://docutils.sourceforge.net/rst.html#user-documentation

http://docutils.sourceforge.net/docs/user/rst/quickref.html

rst 文件是轻量级标记语言的一种,被设计为容易阅读和编写的纯文本,并且可以借助Docutils这样的程序进行文档处理,也可以转换为HTML或PDF等多种格式, 或由Sphinx-Doc这样的程序转换为LaTex、man等更多格式。

这里记录下常见的语法,更多内容请参考官方手册。

标题

可以表示标题的符号有:

= - ` : ' " ~ ^ _  * + # < >

示例如下:

标题
=================================================

一级标题
-------------------------------------------------

二级标题
`````````````````````````````````````````````````

效果如下:

2qqEVnq.png!web

段落

段落是被空行分割的文字片段,左侧必须对齐(没有空格,或者有相同多的空格)。

列表

可以表示列表的符号有:

-、*、+

不同的符号结尾需要加上空行,下级列表需要有空格缩进。

示例如下:

- 列表1

    - 子列表1

    * 子列表2

    + 子列表3

* 列表2

+ 列表3

效果如下:

  • 列表1

    • 子列表1
    • 子列表2
    • 子列表3
  • 列表2
  • 列表3

代码块(文字块)

在需要插入文本块的段落后面加上 :: ,接着一个空行,然后就是文字块了。 文字块开头要有缩进,结束标志是新的一段文本贴开头(即没有缩进)。

示例如下:

::

    import os
    os.system("ls")

效果如下:

import os
os.system("ls")

超链接

reStructuredText会自动将网址生成超链接。

比如:

https://github.com/mike-zhang

https://github.com/mike-zhang

另外一种形式:

`mikeGithub <https://github.com/mike-zhang>`_

mikeGithub

图片

示例如下:

.. image:: images/1.png

粗体和斜体

这是 **粗体** ,这是 *斜体*
不留白的\ **粗体**\ 和\ *斜体*\

这是 粗体 ,这是  斜体

不留白的 粗体斜体

上标和下标

- Water: H\ :sub:`2`\ O
- E = mc\ :sup:`2`

J3uym2V.png!web

rst简单示例

rst简单示例如下:

文章标题
===================================================

操作系统 : CentOS7.3.1611_x64

gcc版本 :4.8.5

go 版本 : go1.8.3 linux/amd64

Python 版本 : 2.7.5


一级标题
--------------------------------------
二级标题
`````````````````````````````````````````````````

- 列表1

- 列表2

代码块
::

    import os
    os.system("ls")

图片:

.. image:: images/20120604.1.1.png

超链接:

https://github.com/mike-zhang

`mikeGithub <https://github.com/mike-zhang>`_

本文github地址:

https://github.com/mike-zhang/mikeBlogEssays/blob/master/2018/ 20180905_reStructuredText语法简单说明.rst

欢迎补充


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK