我使用的Hexo相关语法(+Tag)

标签插件和 Front-matter 中的标签不同,它们是用于在文章中快速插入特定内容的插件。

https://hexo.io/zh-cn/docs/tag-plugins.html

评论管理

评论管理

本站其他辅助

模版   自动生成链接标记

目录正则

1
\d+.[ ][ ]

内链

1
{% post_link filename %}

具体参见 引用文章

插入图片

1
![](/images/)

qq分享图

1
&pics=https://cdn.jsdelivr.net/gh/cjh0613/blog@master/images/icons/CJHicon.jpg

未完成

1
(未完成……敬请期待……)

请自行 谷歌/百度:

1
请自行 {% post_link GoogleMirror 谷歌 %}/[百度](https://www.baidu.com)

参考资料

1
2
3
4
5
6
## 参考资料

| 网页链接 |
|:------:|
| [content]() |
| [content]() |

1
[转]
1
2
3
4
5
> 转自 
> 本文为转载文章,请忽略本站默认原创声明,以原始页面为准。
> 如果原始链接永久失效,且其声明、权利人均不可考证,请按本站声明的许可协议,加注失效的原始链接及原作者。
<!-- more -->
## 原文

截断

1
<!-- more -->

插入b视频

1
2
3
<div style="position: relative; width: 100%; height: 0; padding-bottom: 75%;">
<iframe src="//player.bilibili.com/player.html?bvid=BV" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true" style="position: absolute; width: 100%; height: 100%; left: 0; top: 0;"></iframe>
</div>

常见特殊字符

常用特殊字符转译字符对照表:

特殊符号 命名实体 十进制编码
空格 &nbsp; &#160;
全角空格 &emsp; &#12288;
&apos; &#39;
" &quot; &#34;
( &#40;
) &#41;
< &lt; &#60;
> &gt; &#62;
[ &#91;
] &#93;
{ &#123;
} &#125;
´ &acute; &#180;
° &deg; &#176;
® &reg; &#174;
© &copy; &#169;

常用数学转译字符对照表:

特殊符号 命名实体 十进制编码
&le; &#8804;
&ge; &#8805;
&asymp; &#8773;
&ne; &#8800;
&cap; &#8745;
&cup; &#8746;
&ang; &#8736;
&infin; &#8734;
± &plusmn; &#177;
&radic; &#8730;
&sum; &#8722;
&int; &#8747;
Δ &Delta; &#916;

常用希腊字母转译字符对照表:

特殊符号 命名实体 十进制编码
Φ &Phi; &#934;
Ω &Omega; &#937;
α &alpha; &#945;
β &beta; &#946;
γ &gamma; &#947;
δ &delta; &#948;
ε &epsilon; &#949;
ζ &zeta; &#950;
η &eta; &#951;
θ &theta; &#952;
λ &lambda; &#955;
μ &mu; &#956;
ξ &xi; &#958;
π &pi; &#960;
ρ &rho; &#961;
σ &sigma; &#963;
φ &phi; &#966;
ψ &psi; &#968;
ω &omega; &#969;
&part; &#8706;
&empty; &#8709;

插入注释

info 类型的标注从 v2.0.0-rc.0 开始支持,其他类型的标注均从 v1.2.0 开始支持。

实际使用语法如下:

1
2
3
4
{% note [type] [no-icon] %}
**header text**
Any text
{% endnote %}
1
2
3
4
{% note success no-icon %}
**提示**

{% endnote %}
1
2
3
4
{% note info no-icon %}
**提示**

{% endnote %}
1
2
3
4
{% note danger no-icon %}
**错误**

{% endnote %}
1
2
3
4
{% note warning no-icon %}
**警告**

{% endnote %}
1
2
3
4
{% note default no-icon %}
**Success**
This is success note.
{% endnote %}

标签内可以是任意文字,支持 Markdown 和 HTML 语法。

参数:

[type]:标注类型

[no-icon]:是否显示 ICON

举例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!-- With header, With icon -->
{% note success %}
**Success**
This is success note.
{% endnote %}

<!-- With header, No icon -->
{% note success no-icon %}
**Success**
This is success note.
{% endnote %}

<!-- No header, With icon -->
{% note success %}
This is success note.
{% endnote %}

<!-- No header, No icon -->
{% note success no-icon %}
This is success note.
{% endnote %}

全部效果如下:

插入注释

引用块

在文章中插入引言,可包含作者、来源和标题。

别号: quote

1
2
3
{% blockquote [author[, source]] [link] [source_link_title] %}
content
{% endblockquote %}

峡州仙士

1
2
3
{% blockquote 峡州仙士,关于的论述  %}

{% endblockquote %}
峡州仙士关于的论述

没有提供参数,则只输出普通的 blockquote

1
2
3
{% blockquote %}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque hendrerit lacus ut purus iaculis feugiat. Sed nec tempor elit, quis aliquam neque. Curabitur sed diam eget dolor fermentum semper at eu lorem.
{% endblockquote %}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque hendrerit lacus ut purus iaculis feugiat. Sed nec tempor elit, quis aliquam neque. Curabitur sed diam eget dolor fermentum semper at eu lorem.

引用书上的句子

1
2
3
{% blockquote David Levithan, Wide Awake %}
Do not just seek happiness for yourself. Seek happiness for all. Through kindness. Through mercy.
{% endblockquote %}

Do not just seek happiness for yourself. Seek happiness for all. Through kindness. Through mercy.

David LevithanWide Awake

引用 Twitter

1
2
3
{% blockquote @DevDocs https://twitter.com/devdocs/status/356095192085962752 %}
NEW: DevDocs now comes with syntax highlighting. http://devdocs.io
{% endblockquote %}

NEW: DevDocs now comes with syntax highlighting. http://devdocs.io

引用网络上的文章

1
2
3
{% blockquote Seth Godin http://sethgodin.typepad.com/seths_blog/2009/07/welcome-to-island-marketing.html Welcome to Island Marketing %}
Every interaction is both precious and an opportunity to delight.
{% endblockquote %}

Every interaction is both precious and an opportunity to delight.

代码块

在文章中插入代码。

别名: code

1
2
3
{% codeblock [title] [lang:language] [url] [link text] [additional options] %}
code snippet
{% endcodeblock %}

Specify additional options in option:value format, e.g. line_number:false first_line:5.

Extra Options Description Default
line_number Show line number true
highlight Enable code highlighting true
first_line Specify the first line number 1
mark Line highlight specific line(s), each value separated by a comma. Specify number range using a dash
Example: mark:1,4-7,10 will mark line 1, 4 to 7 and 10.
wrap Wrap the code block in <table> true

普通的代码块

1
2
3
{% codeblock %}
alert('Hello World!');
{% endcodeblock %}
1
alert('Hello World!');

指定语言

1
2
3
{% codeblock lang:objc %}
[rectangle setX: 10 y: 10 width: 20 height: 20];
{% endcodeblock %}
1
[rectangle setX: 10 y: 10 width: 20 height: 20];

附加说明

1
2
3
{% codeblock Array.map %}
array.map(callback[, thisArg])
{% endcodeblock %}
Array.map
1
array.map(callback[, thisArg])

附加说明和网址

1
2
3
4
{% codeblock _.compact http://underscorejs.org/#compact Underscore.js %}
_.compact([0, 1, false, 2, '', 3]);
=> [1, 2, 3]
{% endcodeblock %}
_.compactUnderscore.js
1
2
_.compact([0, 1, false, 2, '', 3]);
=> [1, 2, 3]

反引号代码块

另一种形式的代码块,不同的是它使用三个反引号来包裹。

``` [language] [title] [url] [link text] code snippet ```

Pull Quote

在文章中插入 Pull quote。

1
2
3
{% pullquote [class] %}
content
{% endpullquote %}

jsFiddle

在文章中嵌入 jsFiddle。

1
{% jsfiddle shorttag [tabs] [skin] [width] [height] %}

Gist

在文章中嵌入 Gist。

1
{% gist gist_id [filename] %}

iframe

在文章中插入 iframe。

1
{% iframe url [width] [height] %}

Image

在文章中插入指定大小的图片。

1
{% img [class names] /path/to/image [width] [height] '"title text" "alt text"' %}

在文章中插入链接,并自动给外部链接添加 target="_blank" 属性。

1
{% link text url [external] [title] %}

Include Code

插入 source/downloads/code 文件夹内的代码文件。source/downloads/code 不是固定的,取决于你在配置文件中 code_dir 的配置。

1
{% include_code [title] [lang:language] [from:line] [to:line] path/to/file %}

嵌入 test.js 文件全文

1
{% include_code lang:javascript test.js %}

只嵌入第 3 行

1
{% include_code lang:javascript from:3 to:3 test.js %}

嵌入第 5 行至第 8 行

1
{% include_code lang:javascript from:5 to:8 test.js %}

嵌入第 5 行至文件结束

1
{% include_code lang:javascript from:5 test.js %}

嵌入第 1 行至第 8 行

1
{% include_code lang:javascript to:8 test.js %}

Youtube

在文章中插入 Youtube 视频。

1
{% youtube video_id %}

Vimeo

在文章中插入 Vimeo 视频。

1
{% vimeo video_id %}

引用文章

引用其他文章的链接。

1
2
{% post_path filename %}
{% post_link filename [title] [escape] %}

在使用此标签时可以忽略文章文件所在的路径或者文章的永久链接信息、如语言、日期。

例如,在文章中使用 {% post_link how-to-bake-a-cake %} 时,只需有一个名为 how-to-bake-a-cake.md 的文章文件即可。即使这个文件位于站点文件夹的 source/posts/2015-02-my-family-holiday 目录下、或者文章的永久链接是 2018/en/how-to-bake-a-cake,都没有影响。

默认链接文字是文章的标题,你也可以自定义要显示的文本。此时不应该使用 Markdown 语法 []()

默认对文章的标题和自定义标题里的特殊字符进行转义。可以使用escape选项,禁止对特殊字符进行转义。

链接使用文章的标题

{% post_link hexo-3-8-released %}

链接使用自定义文字

{% post_link hexo-3-8-released '通往文章的链接' %}

对标题的特殊字符进行转义

1
{% post_link hexo-4-released 'How to use <b> tag in title' %}

禁止对标题的特殊字符进行转义

1
{% post_link hexo-4-released '<b>bold</b> custom title' false %}

引用资源

引用文章的资源。

1
2
3
{% asset_path filename %}
{% asset_img filename [title] %}
{% asset_link filename [title] [escape] %}

Raw

如果您想在文章中插入 Swig 标签,可以尝试使用 Raw 标签,以免发生解析异常。

1
2
3
{% raw %}
content
{% endraw %}

文章摘要和截断

在文章中使用 <!-- more -->,那么 <!-- more --> 之前的文字将会被视为摘要。首页中将只出现这部分文字,同时这部分文字也会出现在正文之中。

例如:

1
2
3
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
<!-- more -->
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

首页中将只会出现

1
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

正文中则会出现

1
2
3
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

注意,摘要可能会被 Front Matter 中的 excerpt 覆盖。

(您还可以在归档页搜索文章标题)