markdown语法

716 阅读3分钟

markdown

标题

# 标题一
## 标题二
### 标题三
#### 标题四
##### 标题五
###### 标题六 最多6层标题

列表

无序列表

- 列表项1
- 列表项2
- 列表项3
  
* 列表项1
* 列表项2
* 列表项3

  • 列表项1
  • 列表项2
  • 列表项3
  • 列表项1
  • 列表项2
  • 列表项3

有序列表

1. item1 
2. item2
3. item3

1.item1
2.item2
3.item3

文字效果

  • **加粗Ctrl + B** 加粗Ctrl + B

  • *斜体Ctrl + I* 斜体Ctrl + I 或者 _斜体Ctrl + I_ 斜体Ctrl + I

  • ***加粗&斜体*** 加粗&斜体**_加粗&斜体_** 加粗&斜体

  • ~~删除线 ~~ ~~删除线 ~~

  • `<style>原样输出` <style>原样输出

引用

> 区块引用
>>区块嵌套 

区块引用

区块嵌套

分割线

---
***


缩进

&nbsp;&nbsp;段首缩进 空格+回车换行 

&emsp;&emsp;段首缩进 空格+回车换行 

&emsp;&emsp;段首缩进
> 段首缩进

  段首缩进 空格+回车换行

  段首缩进 空格+回车换行

  段首缩进

段首缩进

链接

[百度首页](http://baidu.com)

百度首页

图片

![引入静态资源](https://doc.houdunren.com/xj.png) 

引入静态资源

数学公式

  1. 行内公式
$E=mc^2$

E=mc2E=mc^2

  1. 居中公式块
$$
\sum_{i=0}^n i^2=\frac{(n^2+n)(2n+1)}{6} \tag{1}
$$
i=0ni2=(n2+n)(2n+1)6(1)\sum_{i=0}^n i^2=\frac{(n^2+n)(2n+1)}{6} \tag{1}
  1. 上标和下标
$$
x_i^3+y_i^3=z_i^3
$$
xi3+yi3=zi3x_i^3+y_i^3=z_i^3
  1. 括号
$$
\{[(x_1+x_2)^2-(y_1-y_2)^4]\times w\}
\times (z_1^2-z_2^2) \tag{3}
$$

# 对数
$\lg 10^3$
$\log_2 10$
$\ln (\pi+2)$

# 三角函数
$$
\sin(x+y)+\cos(y+z)+\tan(z+x)+\arcsin(x+y+z) \tag{7}
$$
{[(x1+x2)2(y1y2)4]×w}×(z12z22)(3)\{[(x_1+x_2)^2-(y_1-y_2)^4]\times w\} \times (z_1^2-z_2^2) \tag{3}

lg103\lg 10^3 log210\log_2 10 ln(π+2)\ln (\pi+2)

sin(x+y)+cos(y+z)+tan(z+x)+arcsin(x+y+z)(7)\sin(x+y)+\cos(y+z)+\tan(z+x)+\arcsin(x+y+z) \tag{7}
  1. 累加、累乘、并集和交集
$$
Y_i=\sum_{i=0}^{n} X_i \tag{5}
$$
$$
\sum_{i=1}^n \frac{1}{i^2} \quad and 
\quad \prod_{i=1}^n \frac{1}{i^2} \quad 
and \quad \bigcup_{i=1}^{2} \Bbb{R} 
\quad and \quad \bigcap_{i=1}^3 X_i \tag{6}
$$
Yi=i=0nXi(5)Y_i=\sum_{i=0}^{n} X_i \tag{5}
i=1n1i2andi=1n1i2andi=12Randi=13Xi(6)\sum_{i=1}^n \frac{1}{i^2} \quad and \quad \prod_{i=1}^n \frac{1}{i^2} \quad and \quad \bigcup_{i=1}^{2} \Bbb{R} \quad and \quad \bigcap_{i=1}^3 X_i \tag{6}

GitHub风格的表格

| Tables        |      Are      |  Cool |
| ------------- | :-----------: | ----: |
| col 3 is      | right-aligned | $1600 |
| col 2 is      |   centered    |   $12 |
| zebra stripes |   are neat    |    $1 |
TablesAreCool
col 3 isright-aligned$1600
col 2 iscentered$12
zebra stripesare neat$1

默认表格

| Tables        |      Are      |  Cool |
| ------------- | ------------- | ----- |
| col 3 is      | right-aligned | $1600 |
| col 2 is      |   centered    |   $12 |
| zebra stripes |   are neat    |    $1 |
TablesAreCool
col 3 isright-aligned$1600
col 2 iscentered$12
zebra stripesare neat$1

以下功能由markdown插件提供,VitePress静态网站生成器,支持

Emoji 🎉

:tada: :100:

🎉 💯 :tada: :100:

自定义容器

自定义容器可以通过它们的类型、标题和内容来定义。markdown插件赋予markdown的功能

::: info
This is an info box.
:::

::: tip
This is a tip.
:::

::: warning
This is a warning.
:::

::: danger
This is a dangerous warning.
:::

::: details 点我查看代码,这是自定义标题
This is a details block.
:::

编译后输出样式为: ::: info This is an info box. :::

::: tip This is a tip. :::

::: warning This is a warning. :::

::: danger This is a dangerous warning. :::

::: details This is a details block. :::

通过标注文件类型,可以实现语法高亮效果,

export default { // Highlighted
  data () {
    return {
      msg: `Highlighted!
      This line isn't highlighted,
      but this and the next 2 are.`,
      motd: 'VitePress is awesome',
      lorem: 'ipsum',
    }
  }
}

代码块行样式

export default { // Highlighted
  data () {
    return {
      msg: `Highlighted!
      This line isn't highlighted,
      but this and the next 2 are.`,
      motd: 'VitePress is awesome',// [!code highlight]
      lorem: 'ipsum',// [!code focus]
      q: 'ipsum',// [!code --]
      w: 'ipsum',// [!code ++]
      r: 'ipsum',
      msg: 'Error', // [!code error]
      msg: 'Warning' // [!code warning]
    }
  }
}

启用和禁用行号

// 行号已启用,并从 2 开始
const line3 = 'This is line 3'
const line4 = 'This is line 4'

导入代码片段

// @为源目录 #snippet代码指定部分 2为需要高亮的行数

<<< @/index.md{2}

// #region snippet
function foo() {
  // ..
}
// #endregion snippet

<<< @/index.md{2}

包含markdown文件

代码组

::: code-group

/**
 * @type {import('vitepress').UserConfig}
 */
const config = {
  // ...
}

export default config
import type { UserConfig } from 'vitepress'

const config: UserConfig = {
  // ...
}

export default config

:::