markdown教程

news/2024/5/19 1:38:59 标签: markdown, 流程图, 序列图, 甘特图, 数学公式
markdown_views prism-atom-one-light">

  版权声明:本文章参考了《小书匠markdown 官方教程》。未经作者允许,严禁用于商业出版,否则追究法律责任。网络转载请注明出处,这是对原创者的起码的尊重!!!


1 基本语法

1.1 转义

   右斜线\表示转义,markdown中字符 [、 \、 *、`、$都需需要加上转义符号才能使用原字符。

1.2 标题

  #加空格表示一级标题
  ##加空格表示二级标题
  ###加空格表示三级标题
  ####加空格表示四级标题
  #####加空格表示五级标题
  ######加空格表示六级标题

  注意:只有当#位于一行开头,或引用文字中的一行开头的才会起作用。

1.3 加粗和斜体

  两个*_环绕表示加粗,如**加粗** ,显示效果:加粗
  一个*_环绕表示斜体,如*斜体*, 显示效果:斜体
  三个*_环绕或混用*_表示粗斜体,如***粗斜体***,显示效果:斜体

1.4 删除线和分行线

  两个 ~环绕表示删除线,如~~删除线~~,显示效果:删除线
  三个 * 或 +或 -表示一条横线,如----,显示效果:


1.5 引用

  • >表示引用。
  • 对一段话引用只需在开头使用一次。
  • 引用中可以使用标题粗体斜体粗斜体删除线代码代码块、公式、有序或无序列表。
  • 引用中可以使用链接、图片、跳转、表格,在支持注脚的版本中也可以使用注脚。
  • 可以多层引用
名字年龄
张三10

使用链接,该链接连接到百度

1.6 无序列表

  • *或+或-,分别加空格表示无序列表
    • 每级缩进一个TAB
        1. 可以多层列表
        1. 可以嵌套列表

1.7 有序列表

  1. 有序列表用序号.加空格表示,
  2. 一个TAB为一级缩进
  3. 有序列表每一级都会重新开始排序
    1. 有序列表显示的是实际的序号与输入的序号无关,
    1. 可以多层列表,
    • 可以嵌套列表

注意:大部分情况下,1个TAB,一个空格或两个或三个空格都能正确缩进,但是有些编辑器却无法解析一个空格。所以推荐使用TAB。

1.8 链接与图片

  • 链接有三种方式:
    1. 行内式[描述文字](链接地址 “悬停提示")
    2. 参考式[描述文字][id] ,在任何地方使用 [id](链接地址 “悬停提示"),可以省略id,省略id表示id为描述文字,
    3. 直接链接<完整链接地址>,如:https://www.baidu.com
  • 图片的语法和链接前两种语法一致,只是在开头需要加上一个英文的感叹号 !,表示这是图片。如:![这是行内式连接](www.baidu.com "百度")

1.9 语法嵌套

  所有可在行内使用的语法都可以在其他语法中套用,比如 加粗 可在标题中使用。

1.10 代码和代码块

  • 句内代码用 ` 代码 `表示,例如:int a=2
  • 代码块的每一行用四个空格或一个tab开头

1.11 HTML标签

  • 只要支持GFM的markdown都兼容html标签

2 扩展语法

markdown版本cmdcsdnxiaoshujiang
任务列表支持支持支持
数学公式支持支持支持
代码块高亮支持支持支持
代码块设置行号不支持不支持支持
目录支持支持支持
思维导图目录不支持不支持支持
脚注支持支持支持
缩进支持支持支持
下划线不支持支持支持
文字高亮不支持支持支持
页内跳转支持不支持不支持
锚点跳转不支持支持支持
标签支持不支持支持
字体、颜色、大小不支持支持支持
视频不支持不支持支持
音频不支持不支持支持
附件不支持不支持支持
段代码文字格式不支持不支持支持
流程图支持支持支持
序列图支持支持支持
统计图不支持不支持支持
mermaid 流程图 序列图 甘特图支持支持支持
html支持支持支持
思维导图不支持不支持支持

2.1 任务列表

任务列表,- [] 任务表示未完成- [X] 任务表示已完成, 任务列表也支持多级使用。

  • 未完成
  • 已完成
  • 已完成

2.2 LaTeX数学公式

2.2.1 基本语法

markdown">markdown">```mathjax!
数学公式1
数学公式1
数学公式1
```

2.2.2 公式对齐

  • \begin{align} ... \end{align},使用&表示对齐位置,\\表示换行,\tag{n}标签序号。
markdown">markdown">$$
\begin{align}
h(x) =& \frac{1}{\int_xt(x)\mathrm{d}x} \tag{1} \\
=& \frac{1}{\int_x\eta(x)\mathrm{d}x}g(x)\tag{2}
\end{align}
$$

  显示如下:

markdown%E6%95%99%E7%A8%8B/1.jpg" alt="1" />

  • \begin{eqnarray} ...\end{eqnarray},使用&表示对齐位置
markdown">markdown">$$
\begin{eqnarray}
a & = & b + c \\
& = & d + e + f + g + h + i + j + k + l\\
&& +\: m + n + o \\
& = & p + q + r + s
\end{eqnarray}
$$

  显示如下:

markdown%E6%95%99%E7%A8%8B/2.jpg" alt="2" />

2.2.3 矩阵

  • 简单矩阵—— $$\begin{matrix}…\end{matrix}$$来生成矩阵,其中… 表示的是LaTeX 的矩阵命令,矩阵命令中每一行以 \ \ 结束,矩阵的元素之间用&来分隔开。
markdown">markdown"> $$
  \begin{matrix}
   1 & 2 & 3 \\
   4 & 5 & 6 \\
   7 & 8 & 9
  \end{matrix} \tag{1}
$$

  显示如:
(1) 1 2 3 4 5 6 7 8 9 \begin{matrix} 1 &amp; 2 &amp; 3 \\ 4 &amp; 5 &amp; 6 \\ 7 &amp; 8 &amp; 9 \end{matrix} \tag{1} 147258369(1)

  • 带括号的Matrix——可以给矩阵加上括号,分为两种:使用\left矩阵左括号 ... \right矩阵右括号(其中花括号要进行转义)或者把公式命令中的matrix 改成 pmatrix(圆括号)、bmatrix(方括号)、Bmatrix(花括号)、vmatrix(行列式)、Vmatrix(双竖线)等。
markdown">markdown">$$
 \left\{
 \begin{matrix}
   1 & 2 & 3 \\
   4 & 5 & 6 \\
   7 & 8 & 9
  \end{matrix}
  \right\} \tag{2}
$$

  显示如下:
(2) { 1 2 3 4 5 6 7 8 9 } \left\{ \begin{matrix} 1 &amp; 2 &amp; 3 \\ 4 &amp; 5 &amp; 6 \\ 7 &amp; 8 &amp; 9 \end{matrix} \right\} \tag{2} 147258369(2)

markdown">markdown">$$
 \begin{pmatrix}
   1 & 2 & 3 \\
   4 & 5 & 6 \\
   7 & 8 & 9
  \end{pmatrix} \tag{4}
$$

  显示如下:
(4) ( 1 2 3 4 5 6 7 8 9 ) \begin{pmatrix} 1 &amp; 2 &amp; 3 \\ 4 &amp; 5 &amp; 6 \\ 7 &amp; 8 &amp; 9 \end{pmatrix} \tag{4} 147258369(4)

markdown">markdown">$$
 \begin{bmatrix}
   1 & 2 & 3 \\
   4 & 5 & 6 \\
   7 & 8 & 9
  \end{bmatrix} \tag{5}
$$

  显示如下:
(5) [ 1 2 3 4 5 6 7 8 9 ] \begin{bmatrix} 1 &amp; 2 &amp; 3 \\ 4 &amp; 5 &amp; 6 \\ 7 &amp; 8 &amp; 9 \end{bmatrix} \tag{5} 147258369(5)

markdown">markdown">$$
 \begin{Bmatrix}
   1 & 2 & 3 \\
   4 & 5 & 6 \\
   7 & 8 & 9
  \end{Bmatrix} \tag{5}
$$

  显示如下:
(5) { 1 2 3 4 5 6 7 8 9 } \begin{Bmatrix} 1 &amp; 2 &amp; 3 \\ 4 &amp; 5 &amp; 6 \\ 7 &amp; 8 &amp; 9 \end{Bmatrix} \tag{5} 147258369(5)

markdown">markdown">$$
 \begin{vmatrix}
   1 & 2 & 3 \\
   4 & 5 & 6 \\
   7 & 8 & 9
  \end{vmatrix} \tag{5}
$$

  显示如下:
(5) ∣ 1 2 3 4 5 6 7 8 9 ∣ \begin{vmatrix} 1 &amp; 2 &amp; 3 \\ 4 &amp; 5 &amp; 6 \\ 7 &amp; 8 &amp; 9 \end{vmatrix} \tag{5} 147258369(5)

markdown">markdown">$$
 \begin{Vmatrix}
   1 & 2 & 3 \\
   4 & 5 & 6 \\
   7 & 8 & 9
  \end{Vmatrix} \tag{5}
$$

  显示如下:
(5) ∥ 1 2 3 4 5 6 7 8 9 ∥ \begin{Vmatrix} 1 &amp; 2 &amp; 3 \\ 4 &amp; 5 &amp; 6 \\ 7 &amp; 8 &amp; 9 \end{Vmatrix} \tag{5} 147258369(5)

  • 带省略符号的矩阵——如果矩阵元素太多,可以使用\cdots \ddots \vdots 等省略符号来定义矩阵。
markdown">markdown">$$
\left[
    \begin{matrix}
        1      & 2      & \cdots & 4      \\
        7      & 6      & \cdots & 5      \\
        \vdots & \vdots & \ddots & \vdots \\
        8      & 9      & \cdots & 0      \\
    \end{matrix}
\right]
$$

  显示如下:

[ 1 2 ⋯ 4 7 6 ⋯ 5 ⋮ ⋮ ⋱ ⋮ 8 9 ⋯ 0 ] \left[ \begin{matrix} 1 &amp; 2 &amp; \cdots &amp; 4 \\ 7 &amp; 6 &amp; \cdots &amp; 5 \\ \vdots &amp; \vdots &amp; \ddots &amp; \vdots \\ 8 &amp; 9 &amp; \cdots &amp; 0 \end{matrix} \right] 178269450

  • 带参数的矩阵——比如写增广矩阵,可能需要最右边一列单独考虑。可以用array命令来处理,其中\begin{array}{cc|c}中的c表示居中对齐元素,|用来作为分割列的符号。
markdown">markdown">$$ 
\left[
    \begin{array}{cc|c}
        1 & 2 & 3 \\
        4 & 5 & 6
    \end{array}
\right] \tag{7}
$$

  显示如下:
(7) [ 1 2 3 4 5 6 ] \left[ \begin{array}{cc|c} 1 &amp; 2 &amp; 3 \\ 4 &amp; 5 &amp; 6 \end{array} \right] \tag{7} [142536](7)

  • 行间矩阵——可以使用\bigl(\begin{smallmatrix} ... \end{smallmatrix}\\bigr)
markdown">markdown"> $\bigl( \begin{smallmatrix} a & b \\ c & d \end{smallmatrix} \bigr)$

  显示如下:markdown%E6%95%99%E7%A8%8B/3.jpg" alt="3" />

2.2.4 数学符号

  • 希腊字母——如果使用大写的希腊字母,把命令的首字母变成大写即可,例如 \Gamma 输出的是 Γ \Gamma Γ。如果使用斜体大写希腊字母,再在大写希腊字母的LaTeX命令前加上var,例如\varGamma 生成 Γ \varGamma Γ
命令显示命令显示命令显示命令显示
\alpha α \alpha α\beta β \beta β\gamma γ \gamma γ\delta δ \delta δ
\epsilon ϵ \epsilon ϵ\zeta ζ \zeta ζ\eta η \eta η\theta θ \theta θ
\iota ι \iota ι\kappa κ \kappa κ\lambda λ \lambda λ\mu μ \mu μ
\xi ξ \xi ξ\nu ν \nu ν\pi π \pi π\rho ρ \rho ρ
\sigma σ \sigma σ\tau τ \tau τ\upsilon υ \upsilon υ\phi ϕ \phi ϕ
\chi χ \chi χ\psi ψ \psi ψ\omega ω \omega ω\ell ℓ \ell
  • 和号、积号、积分号、集合、极限
命令显示命令显示
\sum ∑ \sum \int ∫ \int
\sum_{i=1}^{N}$\sum_{i=1}^{N} $\int_{a}^{b} ∫ a b \int_{a}^{b} ab
\prod ∏ \prod \iint ∬ \iint
\prod_{i=1}^{N} ∏ i = 1 N \prod_{i=1}^{N} i=1N\iint_{a}^{b} ∬ D \iint_{D} D
\bigcup ⋃ \bigcup \iiint ∭ \iiint
\bigcup_{i=1}^{N} ⋃ i = 1 N \bigcup_{i=1}^{N} i=1N\iiint_{a}^{b} ∭ ⋂ \iiint_{\bigcap}
\bigcap ⋂ \bigcap \lim lim ⁡ \lim lim
\bigcap_{i=1}^{N} ⋂ i = 1 N \bigcap_{i=1}^{N} i=1N\lim_{x \to 0} lim ⁡ x → 0 \lim_{x \to 0} limx0
  • 三角函数和双曲函数
命令显示命令显示
\sin x sin ⁡ x \sin x sinx\cos x cos ⁡ x \cos x cosx
\tan x tan ⁡ x \tan x tanx\cot x cot ⁡ x \cot x cotx
\sec x sec ⁡ x \sec x secx\csc x csc ⁡ x \csc x cscx
\arcsin x arcsin ⁡ x \arcsin x arcsinx\arccos x arccos ⁡ x \arccos x arccosx
\arctan x arctan ⁡ x \arctan x arctanx
\sinh x sinh ⁡ x \sinh x sinhx\cosh x cosh ⁡ x \cosh x coshx
\tanh x tanh ⁡ x \tanh x tanhx\coth x coth ⁡ x \coth x cothx
  • 根号、上标、下标、分数、括号、空格
命令显示命令显示
\sqrt[3]{2} 2 3 \sqrt[3]{2} 32 X^{3} x 3 x^{3} x3
\sqrt{2} 2 \sqrt{2} 2 x_{3} x 3 x_3 x3
\frac{1}{2} 1 2 \frac{1}{2} 21
  • 特殊数学符号
命令显示命令显示
\dot x x ˙ \dot x x˙\ddot x x ¨ \ddot x x¨
\hat x x ^ \hat x x^\widehat {XYZ} x y z ^ \widehat {xyz} xyz
\bar x x ˉ \bar x xˉ\overline {xyz} x y z ‾ \overline {xyz} xyz
\vec x x ⃗ \vec x x \overrightarrow {xyz} x y z → \overrightarrow {xyz} xyz
\overleftrightarrow {xyz} x y z ↔ \overleftrightarrow {xyz} xyz
  • 特殊符号
命令显示命令显示
( ) ( ) () ()[ ] [ ] [] []
\{\ } { } \{\} {}
a,b a &ThinSpace; b a\,b aba;b a &ThickSpace; b a\;b ab
a\quadb a b a\quad b aba\qquadb a b a\qquad b ab
\$$$$\_ _ \_ _
\backslash \ \backslash \a\\b a b a\\b ab
{n+1 \choose 2k} ( n + 1 2 k ) {n+1 \choose 2k} (2kn+1)\binom{n+1}{2k} ( n + 1 2 k ) \binom{n+1}{2k} (2kn+1)
a\equiv b\pmod n a ≡ b ( m o d n ) a\equiv b\pmod n ab(modn)\tag xKaTeX parse error: \tag works only in display equations
  • 其他符号
命令显示命令显示命令显示命令显示命令显示
\lt &lt; \lt <\gt &gt; \gt >\le ≤ \le \ge ≥ \ge \neq ≠ \neq ̸=
\not\lt ̸ &lt; \not\lt ̸<\not\gt ̸ &gt; \not\gt ̸>\not\le ̸ ≤ \not\le ̸\not\ge ̸ ≥ \not\ge ̸
\times × \times ×\div ÷ \div ÷\pm ± \pm ±\mp ∓ \mp \cdot{xy} ⋅ \cdot
\cup ∪ \cup \cap ∩ \cap \setminus ∖ \setminus
\subset ⊂ \subset \subseteq ⊆ \subseteq \subsetneq ⊊ \subsetneq
\supset ⊃ \supset \supseteq ⊇ \supseteq \supsetneq ⊋ \supsetneq
\in ∈ \in \notin ∉ \notin /\emptyset ∅ \emptyset \varnothing ∅ \varnothing
\to → \to \mapsto ↦ \mapsto
\rightarrow → \rightarrow \leftarrow ← \leftarrow \Rightarrow ⇒ \Rightarrow \Leftarrow ⇐ \Leftarrow
\land ∧ \land \lor ∨ \lor \lnot ¬ \lnot ¬\forall ∀ \forall \exists ∃ \exists
\top ⊤ \top \bot ⊥ \bot \vdash ⊢ \vdash \vDash ⊨ \vDash
\star ⋆ \star \ast ∗ \ast \oplus$ \oplus$\circ ∘ \circ \bullet ∙ \bullet
\approx$\approx $\sim ∼ \sim \simeq ≃ \simeq \cong ≅ \cong \equiv ≡ \equiv
\prec ≺ \prec \lhd ⊲ \lhd \rhd ⊳ \rhd \Re ℜ \Re \Im ℑ \Im
\infty ∞ \infty \aleph_0 ℵ 0 \aleph_0 0\nabla ∇ \nabla \partial ∂ \partial
\ldots … \ldots \cdots ⋯ \cdots \ddots ⋱ \ddots \vdots ⋮ \vdots
  • 字体
命令字体名显示
\mathbb 或 \Bbbblackboard bold A B C D E F G H \mathbb {ABCDEFGH} ABCDEFGH
\mathbfboldface A B C D E F G H \mathbf {ABCDEFGH} ABCDEFGH
\mathtttypewriter A B C D E F G H \mathtt {ABCDEFGH} ABCDEFGH
\mathrmroman A B C D E F G H \mathrm {ABCDEFGH} ABCDEFGH
\mathsfsans-serif A B C D E F G H \mathsf {ABCDEFGH} ABCDEFGH
\mathcalcalligraphic A B C D E F G H \mathcal {ABCDEFGH} ABCDEFGH
\mathscrscript letters A B C D E F G H \mathscr {ABCDEFGH} ABCDEFGH
\mathfrakFraktur A B C D E F G H \mathfrak {ABCDEFGH} ABCDEFGH
  • 分组:同一个元素如果有个多个普通字符,使用大括号括起来表示同组:{a+b}

2.3 增强代码块

  • 在行首使用 ` ` `代码块 ` ` `表示代码块,在第一行的三个` ` ` 后面可以添加对应语言关键字来实现语法高亮,此时语言关键字后面不需要加感叹号,如:
markdown">markdown">```cpp 
int a = 10 ;
int b = 20; 

```

显示如:

  int a = 10 ;
  int b = 20;
  • 支持是否显示行号,默认会显示:
markdown">markdown">```语言关键字?linenums[=true|]false
... ...
... ...

```
  • 支持设置起始行号:
markdown">markdown">```语言关键字?linenums=起始行号
... ...
... ...

```
  • 单独高亮某些行:
markdown">markdown">```语言关键字?linenums&fancy=行号列表
... ...
... ...

```
语言关键字语言关键字
AppleScriptapplescript普通文本text , plain
ActionScript 3.0actionscript3 , as3Pythonpy , python
Shellbash , shellRubyruby , rails , ror , rb
ColdFusioncoldfusion , cfSASS&SCSSsass , scss
Ccpp , cScalascala
C#c# , c-sharp , csharpSQLsql
CSScssVisual Basicvb , vbnet
Delphidelphi , pascal , pasXMLxml , xhtml , xslt , html
diff&patchdiff patchObjective Cobjc , obj-c
Erlangerl , erlangF#f# f-sharp , fsharp
GroovygroovyRr , s , splus
Javajavamatlabmatlab
JavaFXjfx , javafxswiftswift
JavaScriptjs , jscript , javascriptGOgo , golang
Perlperl , pl , Perl
PHPphp
  • 增强代码块还支持根据特定的命令关键字实现特定的功能。此时,关键字后要加上感叹号
命令关键字作用
mathjax数学公式
flow流程图
plot统计图
sequence序列图
mermaidmermaid流程图序列图甘特图
mindmap思维导图

2.4 生成目录

  • 可以在新行[TOC]生成目录。如:

文章目录

  • 1 基本语法
    • 1.1 转义
    • 1.2 标题
    • 1.3 加粗和斜体
    • 1.4 删除线和分行线
    • 1.5 引用
    • 1.6 无序列表
    • 1.7 有序列表
    • 1.8 链接与图片
    • 1.9 语法嵌套
    • 1.10 代码和代码块
    • 1.11 HTML标签
  • 2 扩展语法
    • 2.1 任务列表
    • 2.2 LaTeX数学公式
      • 2.2.1 基本语法
      • 2.2.2 公式对齐
      • 2.2.3 矩阵
      • 2.2.4 数学符号
    • 2.3 增强代码块
    • 2.4 生成目录
    • 2.5 页内跳转
    • 2.7 缩进
    • 2.8 脚注
    • 2.9 文字格式
    • 2.10 标签
    • 2.11 多媒体
    • 2.12 序列图
    • 2.13 统计图
    • 2.14 流程图
      • 2.14.1 flow
      • 3.14.2 graph
    • 2.15 甘特图
    • 2.16 表格
      • 2.16.1 基本表格
      • 2.16.2 扩展表格
      • 3.16.3 增强表格
      • 2.16.4 html表格
    • 2.17 定义列表
    • 2.18 表情
    • 2.19 注音标示
    • 2.20 思维导图

  • 支持显示成思维脑图大纲:[toc!],显示如下:

markdown%E6%95%99%E7%A8%8B/4.jpg" alt="4" />

  • 支持带参数 depth, 显示最深到几层[toc!?depth=2],显示如下:

markdown%E6%95%99%E7%A8%8B/5.jpg" alt="5" />

2.5 页内跳转

  • 页面跳转[页内跳转](#页内文字),比如:[跳到开头](#基本语法),显示如下:

  • 锚点跳转:这是html 的语法, <span id='idname'>跳转文字</span>设置锚点,在其他地方就可以使用[跳转处](#idname) 跳转。

2.7 缩进

缩进使用html的语法&emsp;表示缩进一个中文字符,&ensp;表示缩进一个英文字符。

2.8 脚注

脚注语法: 内容[^id] ,然后在任意行首使用 [^id]:脚注内容

2.9 文字格式

  • 下划线++文本++表示下划线 ,如:++文本++

  • 文本高亮==文本==来做颜色标记,如:文本

  • 上标文字

    • 文字^上角^,显示如:文字上角
    • 文字<sup>上角</sup>,显示如:文字上角
  • 下角下标

    • 文字~下角~,显示如:文字下角
    • 文字<sub>下角</sub>,显示如:文字下角
  • 对齐

    • 文字左对齐: :>文字居左<-
    • 文字右对齐: ->文字居右<:
    • 文字两端对齐: :>两端对齐的文字<:
    • 文字居中: ->文字居中<-
  • 字体、颜色、大小:用<font face="字体名" size=大小 color=颜色>文本内容</font>来设置字体、颜色、大小。

  • 段代码文字格式

    • var >>~~hello~~<< = 'hello world'

    • var >>==hello==<< = 'hello world'

    • var >>**hello**<< = 'hello world'

    • var >>++hello++<< = 'hello world'

    • 显示如下:
      markdown%E6%95%99%E7%A8%8B/6.jpg" alt="6" />

2.10 标签

标签分类,在新行使用tags:标签1 标签2...TAGS:标签名 标签2...,可以给文章贴上标签。

2.11 多媒体

  • 音频:~[文件名](URL)
  • 视频: %[文件名](URL)
  • 附件: =[文件名](URL)

2.12 序列图

markdown">markdown">````mermaid!
sequenceDiagram
... ...
... ...

```
	或

```mermaid
sequenceDiagram!
... ...
... ...

```
  • 定义标题:title: 标题
  • 定义对象(可以省略):participant 对象 [as 别名]
  • 定义注释:note [left of|right of|over] 对象:注释
    • left of, 表示当前对象的左侧
    • right of, 表示当前对象的右侧
    • over, 表示覆盖在当前对象(们)的上面
  • 定义动作:对象1 箭头 对象2:内容
    • -> 不带箭头的实线
    • –> 不带箭头的虚线
    • ->> 带箭头的实线
    • –>> 带箭头的虚线
    • -x 带x带箭头实线 (异步)
    • –x 带x带箭头虚线(异步)
  • 激活/不激活:
    • 第一种:activate|deactivate 对象
    • 第二种:定义动作时在对象2之前加+表示激活,加-表示不激活
  • 循环:
loop Loop-text
... statements ...
end
  • 替代路径alt或opt:
#如果有两条替代路径
alt Describing text
... statements ...
else Describing text
... statements ...
end

#如果只有一条替代路径
opt Describing text
... statements ...
end
  • 示例
markdown">markdown">```mermaid!
sequenceDiagram
title: 序列图sequence(示例)
participant A
participant B
participant C
participant D as test

note left of A: A左侧说明
note over B,C: 覆盖B,C的说明
note right of C: C右侧说明

A->A:自己到自己
A->B:实线不带箭头
A-->B:虚线不带箭头
A->>B:实线带箭头
A-->>B:虚线带箭头
A-xB:带x带箭头实线(异步)
A--xB:带x带箭头虚线(异步)
C->D:激活
activate C
C->D:不激活
deactivate C

C->+D:激活
C->+D:激活
C->-D:不激活
C->-D:不激活

loop 循环
B->C:测试循环
B->>C:测试循环
B-->C:测试循环
B-->>C:测试循环
end
A->>D:首选路径
alt 替代路径1
A->>C: 
C->>D: 
else 替代路径2
A->>B: 
B->>D: 
end
A-->>C: 首选路径
opt 一种替代路径
A-->>B: 
B-->>D: 
end
```
A B C test A左侧说明 覆盖B,C的说明 C右侧说明 自己到自己 实线不带箭头 虚线不带箭头 实线带箭头 虚线带箭头 带x带箭头实线(异步) 带x带箭头虚线(异步) 激活 不激活 激活 激活 不激活 不激活 测试循环 测试循环 测试循环 测试循环 loop [ 循环 ] 首选路径 alt [ 替代路径1 ] [ 替代路径2 ] 首选路径 opt [ 一种替代路径 ] A B C test 序列图sequence(示例)

2.13 统计图

语法格式为:

markdown">markdown">```plot!
{
"data": [ [[0, 0], [1, 1]] ],
"options": { "yaxis": { "max": 1 } }
}
```

显示如图:

markdown%E6%95%99%E7%A8%8B/7.jpg" alt="7" />

2.14 流程图

2.14.1 flow

markdown">markdown">```mermaid
flowchat!
... ...
... ...

  • 定义元素:tag=>type: text_content:>url

    • tag就是一个标签,在第二段连接元素时用type是这个标签的类型
    • type是流程图的基本类型
      • start
      • end
      • operation
      • subroutine
      • condition
      • inputoutput
  • 连接元素:tag1(方向)->tag2(方向)->tag3....

    • 使用 -> 来连接两个元素
    • right,left:表示箭头在当前模块上的起点(默认箭头从下端开始)
    • 对于condition类型,有yes和no两个分支,如示例中的cond(yes)和cond(no)
  • 示例

```mermaid
flowchat
st=>start: START:>www.baidu.com
e=>end: END
in=>inputoutput: input
out=>inputoutput: output
op=>operation: My Operation
sub=>subroutine: My subroute
cond=>condition: Yes or No?
io=>inputoutput: catch something

st->in->op->cond
cond(yes)->out->e
cond(no)->sub
sub(right)->op
Created with Raphaël 2.2.0 START input My Operation Yes or No? output END My subroute yes no

3.14.2 graph

markdown">markdown">```mermaid! 
graph [方向]
... ...
... ...

```
  • 方向:

    • TD或TB( top bottom)表示从上到下(缺省)
    • BT(bottom top)表示从下到上
    • RL(right left)表示从右到左
    • LR(left right)表示从左到右
  • 定义节点:node[text1]

    • 默认节点: A
    • 矩形节点: B[bname]
    • 圆角矩形节点: C(cname)
    • 圆形节点: D((dname))
    • 非对称节点: E>ename]
    • 菱形节点: F{fname}
  • 连接

    • A–>B 实线带箭头
    • A—B 实线不带箭头
    • A–text–>B或A–>|text|B 实线带箭头带标签
    • A–text—B或A—|text|B 实线不带箭头带标签
    • A-.->B 虚线带箭头
    • A-.-B 虚线不带箭头
    • A-.text.->B或A-.->|text|B 虚线带箭头带标签
    • A-.text.-B或A-.-|text|B 虚线不带箭头带标签
  • 定义子流程图

markdown">markdown">subgraph title
    graph definition
end
  • 定义交互

    • js回调:click node callback "js函数名"
    • 打开连接:click node "URL" "注释"
  • 示例

markdown">markdown">```mermaid!
graph BT
A
B[矩形]
C(圆角矩形)
D{菱形}
E((圆形))
F>非对称]

A-->B 
A---B 
A--text-->B
A-->|text|B 
C--text---D
C---|text|D 
C-.->D
C-.-D
E-.text.->F
E-.->|text|F 
E-.text.-F
E-.-|text|F

G-->H
click H "http://www.baidu.com" "This is a link"
```
graph TB
A
B[矩形]
C(圆角矩形)
D{菱形}
E((圆形))
F>非对称]

A-->B 
A---B 
A--text-->B
A-->|text|B 
C--text---D
C---|text|D 
C-.->D
C-.-D
E-.text.->F
E-.->|text|F 
E-.text.-F
E-.-|text|F

G-->H
click H "http://www.baidu.com" "This is a link"

2.15 甘特图

markdown">markdown">```mermaid! 
gantt
... ...
... ...

```
  • 定义时间格式:dateFormat 时间格式
格式字符举列描述
YYYY20144位数字的年
YY142位数字的年
Y-25Year with any number of digits and sign
Q1,2,3,4季度
M 或 MM1…12数字月份
MMM 或 MMMMJan…December英文名月份
DDD1…31
Do1st…31st一月的第几天
DDD 或 DDDD1…365一年的第几天
X1410715640.579Unix 时间戳,单位为秒
x1410715640579Unix 时间戳,单位为毫秒
gggg2014当地的4位数字的年
gg14当地的2位数字的年
w 或 ww1…53一年的第几周
e0…6一周的星期几(数字)
ddd 或 ddddMon…Sunday一周的星期几(英文)
GGGG2014ISO 4位数字的年
GG14ISO 2位数字的年
W 或 WW1…53ISO 一年的第几周
E1…7ISO 一周的星期几(数字)
H 或 HH0…2324小时制的小时(0-23)
h 或 hh1…1212小时制的小时()
k 或 kk1…2424小时制的小时,(1-24)
a 或 Aam pm上午或下午
m 或 mm0…59
s 或 ss0…59
S 或 SS 或 SSS0…999小数秒
Z 或 ZZ+12:00与 UTC 的偏移量,如 ±HH:mm, ±HHmm, or Z
  • 定义部门:section section_name
  • 定义任务:taskname :[crit][,active|done][,task_id][,start_time][,end_time]
    • done :已完成
    • active :未完成
    • crit:重要的,高亮显示
    • id:唯一标识任务
    • start:开始时间
      • 缺省:前一个任务的结束时间
      • 绝对时间:任务开始时间
      • 相对时间:after task_id 表示某任务的结束时间
    • end:结束时间
      • 绝对时间:该任务的截止时间
      • 持续时间:该任务需要多久完成
  • 示例
markdown">markdown">```mermaid!
gantt
    dateFormat YYYY-MM-DD
    title 项目开发流程
    section 项目确定
        需求分析       :done,a1, 2016-06-22, 3d
        可行性报告     :after a1, 5d
        概念验证       :crit,5d
    section 项目实施
        概要设计      :2016-07-05, 5d
        详细设计      :2016-07-08, 10d
        编码          :2016-07-15, 10d
        测试          :2016-07-22, 5d
    section 发布验收
        发布: 2d
        验收: 3d
```
Mon 27 Mon 04 Mon 11 Mon 18 Mon 25 August 需求分析 可行性报告 概念验证 概要设计 详细设计 编码 测试 发布 验收 项目确定 项目实施 发布验收 项目开发流程

2.16 表格

2.16.1 基本表格

markdown">markdown">|姓名|年龄|体重|
|:--|:--:|--:| 
|张三|100|20|    

显示效果:

姓名年龄体重
张三10020
  • 冒号表示对齐方式,分别是左对齐,居中,右对齐,显示如下:
  • 可以在最后一行使用&emsp;&ensp来控制列宽。

2.16.2 扩展表格

markdown">markdown"> 姓名|年龄|体重
 :--|:--:|--:
 张三|100|20  

显示效果:

姓名年龄体重
张三10020

3.16.3 增强表格

提供增强型表格语法扩展功能,支持带标题表格,多表头,多表身,及行单元格合并。语法格式为显示效果::

markdown">markdown">|First Header  | Second Header ||
|First Header  | Second Header | Third Header|
|------------- | -------------|-------------|
表身1Content Cell  | Merge Content Cell||
Content Cell  | Content Cell| Content Cell|

表身2Content Cell  | Merge Content Cell||
Content Cell  | Content Cell| Content Cell|
[表格标题]

显示效果:

markdown%E6%95%99%E7%A8%8B/8.jpg" alt="8" />

2.16.4 html表格

  • <table>...</table> 定义表格

  • <caption>...</caption>定义表格标题

  • <tr>...</tr>定义行

  • <th>...</th>定义表头单元格

  • <td>...</td>定义单元格

  • 表格属性:align和valign定义对齐方式,border定义线宽
    * left
    * right
    * center

  • 单元格属性

    • colspan定义跨列
    • bgcolor定义背景色
    • background定义背景图
    • rowspan定义跨行
    • align和valign定义对齐方式
    • left
    • right
    • center
  • 示例

<table>
  <caption>跨行和跨列,带背景色,和表格表格</caption> 
  <tr>
    <td>&emsp;</td>
    <th colspan='2'><font color="red">跨2列</font></th>
    <th><font color="red">第3列</font></th>
  </tr>
    <th rowspan='2'><font color="blue">跨2行</font></th>
    <td bgcolor="red">1</td>
    <td align="center">2</td>
    <td align="right">3</td>
  <tr>
    <td bgcolor="red" >1</td>
    <td align="center">2</td>
    <td align="right">3</td>
  </tr>
  <tr>
    <th><font color="blue">第3行</font></th>
    <td bgcolor="red">1</td>
    <td align="center">2</td>
    <td align="right">3</td>
  </tr>
</table>

显示如下:

跨行和跨列,带背景色,和表格表格
跨2列第3列
跨2行123
123
第3行123

  版权声明:本文章参考了《小书匠markdown 官方教程》。未经作者允许,严禁用于商业出版,否则追究法律责任。网络转载请注明出处,这是对原创者的起码的尊重!!!


2.17 定义列表

markdown">markdown">苹果
: 	一种水果
: 	一种品牌,计算机,手持设备
桔子
: 一种水果

显示效果:

苹果
一种水果
一种品牌,计算机,手持设备
桔子
一种水果

2.18 表情

  • 格式::表情名:,如:wink:, :crush:, :cry:, :tear:, :laughing:, :yum:
  • 显示如下:markdown%E6%95%99%E7%A8%8B/11.jpg" alt="11" />

2.19 注音标示

语法格式为:

markdown">markdown">{需要被注音标示的内容}(注音标示)

或者:
 
{需要被注音标示的内容}[编号]
[编号]: 注音标示`

显示效果: markdown%E6%95%99%E7%A8%8B/10.jpg" alt="10" />

2.20 思维导图

语法格式为:

markdown">markdown">```mindmap!?root=思维脑图&title=思维脑图测试&theme=gray&direction=v
分支一
    a子分子一
    a子分子二
分支二
    b子分子一
    b子分子二
分支三
    c子分子一
    c子分子二
```

提供的参数有 :

  • direction: lr, rl, tb, bt, h, v. 默认为 h
  • theme: gray, colorful. 默认为 colorful
  • title: 使用 encodeURI 编码的字符串,用于在思维脑图下方显示. 默认为空
  • root: 使用 encodeURI 编码的字符串,用户在思维脑图的根节点。如果用户的数据里已经有根节点,可以不需要指定。默认为 root

显示效果:
markdown%E6%95%99%E7%A8%8B/9.jpg" alt="9" />


http://www.niftyadmin.cn/n/1822747.html

相关文章

最方便的方法8192EU无线网卡在ubuntu14.04下驱动编译错误解决

亏爹的intel 7260网卡&#xff0c;一直断线&#xff0c;只能用usb的网卡。网上买了两个&#xff0c;发现驱动都太旧了&#xff0c;编译不过&#xff0c;改了一下代码&#xff0c;可以用了。 ps&#xff1a;有的网卡linux自带驱动&#xff0c;但会断线&#xff0c;也可以编译一下…

Mysql 更新时间(加上或者减去一段时间)

Mysql时间加减函数为date_add&#xff08;&#xff09;、date_sub&#xff08;&#xff09;定义和用法DATE_ADD() 函数向日期添加指定的时间间隔。DATE_SUB() 函数向日期减少指定的时间间隔。语法DATE_ADD(date,INTERVAL expr type)DATE_SUB(date,INTERVAL expr type)date 参数…

通过Vbs部署Symantec client

实验要求&#xff1a; 域客户端分发安装symantec client windows2003、windows2008R2、windows2012不安装 思路介绍 我们说说道软件分发&#xff0c;大家肯定第一时间想到的是通过Group policy 通过AD Policy部署软件,但是由于系统分为x86、x64&#xff1b;同时软件也分为x86、…

P1637 三元上升子序列

题目描述 Erwin最近对一种叫"thair"的东西巨感兴趣。。。 在含有n个整数的序列a1,a2......an中&#xff0c; 三个数被称作"thair"当且仅当i<j<k且ai<aj<ak 求一个序列中"thair"的个数。 输入输出格式 输入格式&#xff1a;开始一个正…

20172319 《程序设计与数据结构》 第八周学习总结

20172319 2018.11.04-11.11《程序设计与数据结构》第8周学习总结目录教材学习内容总结教材学习中的问题和解决过程代码调试中的问题和解决过程代码托管上周考试错题总结结对及互评学习进度条参考资料教材学习内容总结第十二章 优先队列与堆 12.1 堆&#xff1a;堆&#xff08;…

Linux系统日志管理:(2)进程统计日志

Linux操作系统中有三种主要的日志子系统&#xff1a; &#xff08;1&#xff09;连接时间日志 &#xff08;2&#xff09;进程统计日志 &#xff08;3&#xff09;系统和服务日志 连接时间日志和进程统计日志由rsyslog(旧版是syslog)日志服务驱动,系统和服务日志由相对应的网络…

OpenSSL中文手册之安装教程

版权声明&#xff1a; 未经作者允许&#xff0c;严禁用于商业出版&#xff0c;否则追究法律责任。网络转载请注明出处&#xff0c;这是对原创者的起码的尊重&#xff01;&#xff01;&#xff01; 1 apt 安装 sudo apt update  sudo apt install openssl  sudo apt install…

package.xml

package.xml 也是一个catkin的package必备文件&#xff0c; 它是这个软件包的描述文件&#xff0c; 在较早的ROS版本(rosbuild编译系统)中&#xff0c; 这个文件叫做 manifest.xml &#xff0c; 用于描述pacakge的基本信息。 如果你在网上看到一些ROS项目里包含着 manifest.xml…