Markdown 语法手册

来源:互联网 发布:影楼调色软件 编辑:程序博客网 时间:2024/05/16 01:41

Markdown 语法手册


1. 分级标题

使用 === 表示一级标题,使用 — 表示二级标题。

示例:

这是一个一级标题

这是一个二级标题

你也可以选择在行首加井号表示不同级别的标题 (H1-H6),例如:# H1, ## H2, ### H3,#### H4。

这是一个三级标题

2. 斜体和粗体

使用 * 或 _ 表示斜体,使用 ** 或 __ 表示粗体。

示例:

这是 斜体,这是 粗体
这也是 斜体,这也是 粗体

3. 无序列表

使用 *,+,- 表示无序列表。

示例:

  • 无序列表项 一
  • 无序列表项 二
  • 无序列表项 三

4. 有序列表

使用数字和点表示有序列表。

示例:

  1. 有序列表项 一
  2. 有序列表项 二
  3. 有序列表项 三

当然,项目列表很可能会不小心产生,像是下面这样的写法:

  1. What a great year.

换句话说,也就是在行首出现数字-句点-空白,要避免这样的状况,你可以在句点前面加上反斜杠。

1986. What a great year.

5. 文字引用

使用 > 表示文字引用。

示例:

野火烧不尽,春风吹又生。

文字引用可以嵌套(例如:引用内的引用),只要根据层次加上不同数量的 > :

This is the first level of quoting.

This is nested blockquote.

Back to the first level.

6. 分割线

你可以在一行中用三个以上的星号、减号、底线来建立一个分隔线,行内不能有其他东西。你也可以在星号或是减号中间插入空格。下面每种写法都可以建立分隔线:






7. 链接

Markdown 支持两种形式的链接语法:行内式参考式两种形式。

不管是哪一种,链接文字都是用 [方括号] 来标记。

要建立一个行内式的链接,只要在方括号后面紧接着圆括号并插入网址链接即可,如果你还想要加上链接的 title 文字,只要在网址后面,用双引号把 title 文字包起来即可,例如:

This is Baidu inline link.

Baidu has no title attribute.

参考式的链接是在链接文字的方括号后面再接上另一个方括号,而在第二个方括号里面要填入用以辨识链接的标记:

This is Apple link.

接着,在文件的任意处,你可以把这个标记的链接内容定义出来,链接内容定义的形式为:

  • 方括号里面输入链接文字
  • 接着一个冒号
  • 接着一个以上的空格或制表符
  • 接着链接的网址
  • 选择性地接着 title 内容,可以用单引号、双引号或是括弧包着

隐式链接标记功能让你可以省略指定链接标记,这种情形下,链接标记会视为等同于链接文字,要用隐式链接标记只要在链接文字后面加上一个空的方括号,如果你要让 “Linkedin” 链接到官网,你可以简化成:

Linkedin

8. 插入图片

很明显的,要在纯文字应用中设计一个自然的语法来插入图片是有一定难度的。

Markdown 使用一种和链接很相似的语法来标记图片,区别在一个 ! 号,同样也允许两种样式:行内式参考式

行内式插入图片:

ECNU

参考式插入图片:

ECNU

到目前为止,Markdown 还没有办法指定图片的宽高。

9. 代码块

行内代码

使用 `代码` 表示行内代码块。

示例:

让我们聊聊 R

代码块

使用四个缩进空格表示代码块。

示例:

这是一个代码块,此行左侧有四个不可见的空格。install.packages("tkrplot", type="source")

另一种表示代码块方式:

install.packages("tkrplot", type="source")

10. 删除线

使用 ~~ 表示删除线。

这是一段错误的文本。

11. 注脚

使用 [^keyword] 表示注脚。

这是第一个注脚1的样例。

这是第二个注脚[^footnote2]的样例。

12. LaTeX 公式

  1. Math rendering is disabled by default, to enable it, check on the Enable Math option in Preferences > General > All Documents.

  2. Make sure you’ve connected to the internet.

    The Math rendering is powered by MathJax, the resources such as fonts are all online, thus the internet connection is needed for it to work.

  3. For Users in mainland China

    Users in mainland China, if the Math option doesn’t work for you, try if you can visit MathJax without VPN connected. If you can’t, maybe it’s blocked by the Great Firewall of China. Try connect to a VPN, climb over the wall, then the Math rendering should work.

Block level vs Inline level

Use double US dollors sign pair for Block level Math formula, and three US dollors sign pair for Inline Level.

For example this is a Block level

x=b±b24ac2a
formula, and this is an inline Level
$x=b±b24ac2a
$ formula.

The Math Syntax

The syntax is the same as TeX, except one thing:

Because the characters such as \ and _ and * and so on have special meanings in Markdown language, you need to add an extra \ character before them to escape them to make the Math renders correctly.

For example in TeX syntax it starts with [ but here you need to add an extra \ to escape it, thus \[

And so on… Luckily you don’t have to escape every \ characters, normally escape the beginning [ and ending ] is enough, and perhaps \ to \.

The Lorenz Equations

x˙ y˙ z˙=σ(yx)=ρxyxz=βz+xy

The Cauchy-Schwarz Inequality

(k=1nakbk)2(k=1na2k)(k=1nb2k)

A Cross Product Formula

V1×V2=i Xu XvjYuYvk00

An Identity of Ramanujan

1(ϕ5ϕ)e25π=1+e2π1+e4π1+e6π1+e8π1+

Maxwell’s Equations

×B⃗ 1cE⃗ tE⃗ ×E⃗ +1cB⃗ tB⃗ =4πcj⃗ =4πρ=0⃗ =0

A Rogers-Ramanujan Identity

1+q2(1q)+q6(1q)(1q2)+=j=01(1q5j+2)(1q5j+3),for |q|<1.

13. 表格

A simple table looks like this:

First Header Second Header Third Header Content Cell Content Cell Content Cell Content Cell Content Cell Content Cell

If you wish, you can add a leading and tailing pipe to each line of the table:

First Header Second Header Third Header Content Cell Content Cell Content Cell Content Cell Content Cell Content Cell

Specify alignment for each column by adding colons to separator lines:

First Header Second Header Third Header Left Center Right Left Center Right 项目 价格 数量 计算机 $1600 5 手机 $900 12 管线 $1 234

  1. 这是第一个 注脚文本
    [^footnote2]: 这是第二个 注脚文本。 ↩
0 0
原创粉丝点击