常见的Markdown语法,例如引用、标题、段落、无序列表、有序列表等不做讨论。

参考:Sulv’s Blog荷戟独彷徨Memory3rd’s BlogDoit

字体种类

在Markdown中,使用<font>标签的face属性修改文字字体:

1
2
3
<font face='SimHei'>这是黑体</font>
<font face='KaiTi'>这是楷体</font>
<font face='Fangsong_GB2312'>这是仿宋_GB2312字体</font>

这是黑体 
这是楷体 
这是仿宋_GB2312字体

字体名称
字体写法
黑体 SimHei
宋体 SimSun
新宋体 NSimSun
仿宋 FangSong
楷体 KaiTi
仿宋_GB2312 FangSong_GB2312
楷体_GB2312 KaiTi_GB2312
微软雅黑 Microsoft YaHei
落霞文楷 LXGW WenKai
落霞文楷 Lite LXGW WenKai Lite
落霞文楷 Screen LXGW WenKai Screen
落霞文楷 TC LXGW WenKai TC

字号

1
2
3
4
5
6
7
<font size="1">这是1号字体</font>
<font size="2">这是2号字体</font>
<font size="3">这是3号字体</font>
<font size="4">这是4号字体</font>
<font size="5">这是5号字体</font>
<font size="6">这是6号字体</font>
<font size="7">这是7号字体</font>

这是1号字体
这是2号字体 
这是3号字体  
这是4号字体 
这是5号字体 
这是6号字体 
这是7号字体 


字体颜色

1
2
3
4
<font color='red'>这是红色字体</font>
<font color='rgb(200, 100, 100)'>这是rgb(200, 100, 100)颜色字体</font>
<font color='#FF00BB'>这是#FF00BB颜色字体</font>
<font style="background: linear-gradient(to right, #ff1616, #36c945, #10a5ce, #0f0096, #a51eff, #ff1616);">这是7色渐变颜色</font>

这是红色字体 
这是rgb(200, 100, 100)颜色字体 
这是#FF00BB颜色字体
这是7色渐变颜色


待办列表

使用-[]表示一项待办,当完成待办后给中括号中添加x(不区分大小写,注意空格不可省略)即可,例如:

1
2
3
- [x] 吃饭
- [x] 睡觉
- [ ] 写作业
  • 吃饭
  • 睡觉
  • 写作业

脚注和页内跳转

脚注

1
2
3
这是一个简单的脚注[^1],这是另一个脚注[^bignote][^1]:这是第一个脚注
[^bignote]:这是第二脚注

这是一个简单的脚注1,这是另一个脚注2

页内跳转

1
2
3
4
5
6
7
// 1. 首先定义一个锚点:
<span id="jump">**<u>《塞尔达传说 王国之泪》</u>**</span>(日语:ゼルダの伝説 ティアーズ オブ ザ キングダム,英语:The Legend of Zelda: Tears of the Kingdom)是一款由任天堂企划制作本部开发,任天堂发行的一款开放世界动作冒险游戏。本作为2017年发售的《塞尔达传说 旷野之息》的续作,也是塞尔达传说系列的第二十部作品,于2023年5月12日在任天堂Switch上发售。

// 2. 用markdown的语法写超链
点击查看[王国之泪的介绍](#jump)

// 3. 点击超链文字就可以定位到跳转内容了

点击查看王国之泪的介绍

《塞尔达传说 王国之泪》(日语:ゼルダの伝説 ティアーズ オブ ザ キングダム,英语:The Legend of Zelda: Tears of the Kingdom)是一款由任天堂企划制作本部开发,任天堂发行的一款开放世界动作冒险游戏。本作为2017年发售的《塞尔达传说 旷野之息》的续作,也是塞尔达传说系列的第二十部作品,于2023年5月12日在任天堂Switch上发售。

另外,也可以用上标的方式进行页内跳转:

1
王国之泪<sup>[[塞尔达传说 王国之泪]](#jump)</sup>是什么游戏?

王国之泪[塞尔达传说 王国之泪]是什么游戏?

鼠标悬浮效果

1
<abbr title="🙃🙃🙃">鼠标悬浮这里</abbr>可以看到详细的解释。

鼠标悬浮这里 可以看到详细的解释。


自定义shortcodes

Hugo博客通过简码方式插入pdf、bilibili以及博客文章内链等功能。

为了防止被识别生效,调用样式均表示为{.{< xxx >}},实际使用时去掉大括号中间的.即可。

不同颜色的信息框

1
2
3
4
5
6
{.{< black message="这是一条黑白信息" >}}
{.{< grey message="这是一条灰色信息" >}}
{.{< blue message="这是一条蓝色信息" >}}
{.{< green message="这是一条绿色信息" >}}
{.{< yellow message="这是一条黄色信息" >}}
{.{< red message="这是一条红色信息" >}}
不同颜色的信息框

插入pdf

1
{.{< ppt src="https://www.africau.edu/images/default/sample.pdf" >}} 

插入bilibili视频

1
2
{.{< bilibili BV1WZ4y1a7MF >}}
# 如果有集数(默认第一集),例如要播放第5集,则这样使用:{.{< bilibili BV1WZ4y1a7MF 5 >}}

插入博客文章内链

1
2
{.{< innerlink src="posts/tech/cs-basic-grammar.md" >}}
# 卡片获取的文章长度默认是70,需要在config.yaml配置文件添加 summaryLength: 90,即设置为90
计算机基础知识总结(语法篇)
日期: 2023-05-09   标签: #C++  #基础知识 
成员变量初始化 构造函数内部初始化和初始化列表 初始化类的成员有两种方式,一是使用初始化列表,二是在构造函数体内进行赋值操作。 对于内置类型,如int, float等,使用初始化列表和在构 ......

代码围栏

格式示例:

1
2
3
```java {lineNos=true,lineNumbersInTable=true,style=monokai,linenostart=66,hl_lines=[8,"15-17"]}
// code ...
```

效果:

66@EnableOpenApi
67public class Swagger3Config {
68    @Value("${swagger.enabled}")
69    Boolean swaggerEnabled;
70
71    @Bean
72    public Docket docket() {
73        return new Docket(DocumentationType.OAS_30)
74                .enable(swaggerEnabled)
75                .apiInfo(builderApiInfo())
76                .select()
77                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
78                .paths(PathSelectors.any())
79                .paths(PathSelectors.regex("/error").negate())
80                .build();
81    }
82
83    private ApiInfo builderApiInfo() {
84        return new ApiInfoBuilder()
85                .contact(new Contact(
86                        "sa-token-demo",
87                        "127.0.0.1:8888",
88                        ""
89                ))
90                .title("sa-token-demo")
91                .description("项目接口文档")
92                .version("v1.0.0")
93                .build();
94    }
95}

代码折叠

1
2
3
4
5
6
7
8
9
{.{% code %}}
```cpp
#include <iostream>
int main() {
    std::cout << "Hello World!" << std::endl;
    return 0;
}
```
{.{% /code %}}
代码
1
2
3
4
5
#include <iostream>
int main() {
    std::cout << "Hello World!" << std::endl;
    return 0;
}

文字位置

1
2
3
{.{< align left "文字居左" >}}
{.{< align center "文字居中" >}}
{.{< align right "文字居中" >}}

文字居左

文字居中

文字居中

图片

figure标签是PaperMod主题自带的

1
2
{.{< figure src="https://kdjlyy.github.io/img/logo.ico" caption="图片描述" width="50%" height="50%" align="center" >}}
{.{< figure src="https://kdjlyy.github.io/img/logo.ico" title="xxx"  caption="图片描述" width="200" height="200" >}}
图片描述

图片描述

或者:

1
2
3
4
<div style="text-align:center;">
  <img style="display: block; margin: 0 auto;" src="" width="100%" height="100%" >
  <span style="font-size: 14px; color: grey;">图片描述</span>
</div><br>
头像

Github卡片

1
{.{< github title="kdjlyy/fastRPC" >}}

Mermaid作图

1
2
3
4
5
6
7
8
<div align=center>
<!-- 可以用html代码包裹该代码实现居中或其他排版 -->
{.{<mermaid>}}
flowchart LR
  a --> b & c --> d
{.{</mermaid>}}

</div>
flowchart LR a --> b & c --> d

流程图

代码
1
2
3
4
5
6
{.{< mermaid >}}graph LR;
    A[Hard edge] -->|Link text| B(Round edge)
    B --> C{Decision}
    C -->|One| D[Result one]
    C -->|Two| E[Result two]
{.{< /mermaid >}}
graph LR; A[Hard edge] -->|Link text| B(Round edge) B --> C{Decision} C -->|One| D[Result one] C -->|Two| E[Result two]

时序图

代码
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
{.{< mermaid >}}sequenceDiagram
    participant Alice
    participant Bob
    Alice->>John: Hello John, how are you?
    loop Healthcheck
        John->John: Fight against hypochondria
    end
    Note right of John: Rational thoughts <br/>prevail...
    John-->Alice: Great!
    John->Bob: How about you?
    Bob-->John: Jolly good!
{.{< /mermaid >}}
sequenceDiagram participant Alice participant Bob Alice->>John: Hello John, how are you? loop Healthcheck John->John: Fight against hypochondria end Note right of John: Rational thoughts
prevail... John-->Alice: Great! John->Bob: How about you? Bob-->John: Jolly good!

甘特图

代码
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
{ {< mermaid >}}gantt
    dateFormat  YYYY-MM-DD
    title Adding GANTT diagram functionality to mermaid
    section A section
    Completed task            :done,    des1, 2014-01-06,2014-01-08
    Active task               :active,  des2, 2014-01-09, 3d
    Future task               :         des3, after des2, 5d
    Future task2               :         des4, after des3, 5d
    section Critical tasks
    Completed task in the critical line :crit, done, 2014-01-06,24h
    Implement parser and jison          :crit, done, after des1, 2d
    Create tests for parser             :crit, active, 3d
    Future task in critical line        :crit, 5d
    Create tests for renderer           :2d
    Add to mermaid                      :1d
{ {< /mermaid >}}
gantt dateFormat YYYY-MM-DD title Adding GANTT diagram functionality to mermaid section A section Completed task :done, des1, 2014-01-06,2014-01-08 Active task :active, des2, 2014-01-09, 3d Future task : des3, after des2, 5d Future task2 : des4, after des3, 5d section Critical tasks Completed task in the critical line :crit, done, 2014-01-06,24h Implement parser and jison :crit, done, after des1, 2d Create tests for parser :crit, active, 3d Future task in critical line :crit, 5d Create tests for renderer :2d Add to mermaid :1d

类图

代码
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{ {< mermaid >}}classDiagram
    Class01 <|-- AveryLongClass : Cool
    Class03 *-- Class04
    Class05 o-- Class06
    Class07 .. Class08
    Class09 --> C2 : Where am i?
    Class09 --* C3
    Class09 --|> Class07
    Class07 : equals()
    Class07 : Object[] elementData
    Class01 : size()
    Class01 : int chimp
    Class01 : int gorilla
    Class08 <--> C2: Cool label
{ {< /mermaid >}}
classDiagram Class01 <|-- AveryLongClass : Cool Class03 *-- Class04 Class05 o-- Class06 Class07 .. Class08 Class09 --> C2 : Where am i? Class09 --* C3 Class09 --|> Class07 Class07 : equals() Class07 : Object[] elementData Class01 : size() Class01 : int chimp Class01 : int gorilla Class08 <--> C2: Cool label

状态图

代码
1
2
3
4
5
6
7
8
{.{< mermaid >}}stateDiagram
    [*] --> Still
    Still --> [*]
    Still --> Moving
    Moving --> Still
    Moving --> Crash
    Crash --> [*]
{.{< /mermaid >}}
stateDiagram [*] --> Still Still --> [*] Still --> Moving Moving --> Still Moving --> Crash Crash --> [*]

Git图

代码
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{ {< mermaid >}}
gitGraph
    commit
    branch hotfix
    checkout hotfix
    commit
    branch develop
    checkout develop
    commit id:"ash" tag:"abc"
    branch featureB
    checkout featureB
    commit type:HIGHLIGHT
    checkout main
    checkout hotfix
    commit type:NORMAL
    checkout develop
    commit type:REVERSE
    checkout featureB
    commit
    checkout main
    merge hotfix
    checkout featureB
    commit
    checkout develop
    branch featureA
    commit
    checkout develop
    merge hotfix
    checkout featureA
    commit
    checkout featureB
    commit
    checkout develop
    merge featureA
    branch release
    checkout release
    commit
    checkout main
    commit
    checkout release
    merge main
    checkout develop
    merge release
{ {< /mermaid >}}
gitGraph commit branch hotfix checkout hotfix commit branch develop checkout develop commit id:"ash" tag:"abc" branch featureB checkout featureB commit type:HIGHLIGHT checkout main checkout hotfix commit type:NORMAL checkout develop commit type:REVERSE checkout featureB commit checkout main merge hotfix checkout featureB commit checkout develop branch featureA commit checkout develop merge hotfix checkout featureA commit checkout featureB commit checkout develop merge featureA branch release checkout release commit checkout main commit checkout release merge main checkout develop merge release

饼图

代码
1
2
3
4
5
6
7
<div class="mermaid">
    pie
    "Dogs" : 386
    "Cats" : 85
    "Rats" : 15

</div>
pie "Dogs" : 386 "Cats" : 85 "Rats" : 15

Echarts作图

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<div id="echarts" style="width: 600px;height:400px;"></div>
<script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.1.1/echarts.min.js"></script>
<script>
var myChart = echarts.init(document.getElementById('echarts'));
myChart.setOption({
    title: { text: 'ECharts 示例' },
    tooltip: {},
    xAxis: {
        data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    },
    yAxis: {},
    series: [{
        name: '销量',
        type: 'bar',
        data: [5, 20, 36, 10, 10, 20, 5]
    }]
});
</script>

其他

上标和下标

1
2
3
H<sub>2</sub>O
C<sub>6</sub>H<sub>12</sub>O<sub>6</sub>
X<sup>n</sup> + Y<sup>n</sup> = Z<sup>n</sup>

H2O
C6H12O
Xn + Yn = Z

公式

1
$$0.414213562373095048\approx6\*16^{-1}+a\*16^{-2}+0\*16^{-3}+\cdots$$

$$0.414213562373095048\approx6*16^{-1}+a*16^{-2}+0*16^{-3}+\cdots$$

文字高亮

1
<mark>高亮标记语言</mark>显示段落中的重要文字部分。

高亮标记语言显示段落中的重要文字部分。


  1. 这是第一个脚注 ↩︎

  2. 这是第二个脚注 ↩︎