Markdown和reStructuredText语法比较

文/fasiondog

来源:http://fasiondog.cn/archives/698.html

Markdown语法简单,适用于大多数电子书籍的书写使用。reStructuredText语法比较复杂但功能会更多,尤其是Python官方定为帮助文档撰写的指定工具Sphinx,对函数等的索引引用比较方便。简单整理一下语法差异,供备用查询。

Markdown语法参考:Sourceforge的语法帮助 http://sourceforge.net/p/hikyuu/wiki/markdown_syntax/#md_ex_links
reStructuredText语法参考:Sphinx的文档帮助 http://sphinx-doc.org/rest.html#rst-primer

整理:fasondog

Markdown reStructuredText
Links

​<http://someurl>

[test描述](http://test)

或者

You can also put the [link URL][1] .

  [1]: http://url

`text <http://url>`_

或者:

This is a paragraph that contains `a link`_.

.. _a link: http://example.com/

注释 NA .. This is a comment.
斜体 *this is in italic* *this is in italic*
粗体 **this is in bold** **this is in bold**
粗斜体 ***this is bold and italic*** 未见
删除线 <s>this is strike through text</s> 未见
引文 Blockquotes > Use…… | These lines are(|前要有空格)
Preformatted Text    This line won’t *have any markdown* formatting applied. (前面加4个以上的空格 未见
列表

* and this is ……

+ or you can ……

– or the – character

1. this starts ……

* This is a bulleted list.

1. This is a numbered list.

#. This is a numbered list.

Images ![alternate text]
(https://url/x.gif)

.. image:: gnu.png

  (options)

Footnotes 不支持

Lorem ipsum [#f1]_ dolor sit amet … [#f2]_

.. rubric:: Footnotes

.. [#f1] Text of the first footnote.

.. [#f2] Text of the second footnote.

引用 Citations 不支持

Lorem ipsum [Ref]_ dolor sit amet.

.. [Ref] Book or article reference, URL or whatever.

(和Footnotes类似)

Headers

This is a huge header

==================

this is a smaller header

——————

More:

# this is a huge header #

## this is a smaller header ##

### this is even smaller ###

#### more small ####

##### even smaller #####

###### smallest still: `<h6>` header

Section Title

=============

Section Title

————-

Section Title

““““““`

Section Title

””””””’

Section Title

………….

Section Title

~~~~~~~~~~~~~

Section Title

*************

Section Title

+++++++++++++

Section Title

^^^^^^^^^^^^^

Cross-referencing NA

Sphinx特有

.. _my-reference-label:

Section to cross-reference

————————–

This is the text of the section.

It refers to the section itself, see :ref:`my-reference-label`.

工程组织

依靠Links组织不同的文件,如:

markdown

* 1.[Go环境配置](01.0.md)

– 1.1. [Go安装](01.1.md)

– 1.2. [GOPATH 与工作空间](01.2.md)

– 1.3. [Go 命令](01.3.md)

– 1.4. [Go开发工具](01.4.md)

– 1.5. [小结](01.5.md)

.. toctree::

  :maxdepth: 2

  developer/Prerequisites

  developer/Hikyuu_core

  developer/FAQ

目录

(在同一个文件中)

[TOC]

# Section 1

## Sub-section 1

# Section 2

NA
上标/下标 NA

:sub:`text`

:sup:`text`

(这也是reStucturedText通用描述方式

:rolename:`text`)

表格 见下 见下

Markdown表格表示:

  First Header  | Second Header
  ------------- | -------------
  Content Cell  | Content Cell
  Content Cell  | Content Cell

reStructuredText表格表示:

=====  =====  =======

A      B      A and B

=====  =====  =======

False  False  False

True   False  False

False  True   False

True   True   True

=====  =====  =======

+————————+————+———-+———-+

| Header row, column 1   | Header 2   | Header 3 | Header 4 |

| (header rows optional) |            |          |          |

+========================+============+==========+==========+

| body row 1, column 1   | column 2   | column 3 | column 4 |

+————————+————+———-+———-+

| body row 2             | …        | …      |          |

+————————+————+———-+———-+  

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注