Markdown常用样式

# 可表示1-6级标题

斜体 : *斜体*
粗体 : **粗体**
粗体加斜体 : ***粗体***

🐫 😊 😄 : :smil\e:(去掉斜线)
分割线(下面这条) : ---


上角标 : ^上角标^
下角标 : ~下角标~
删除线 : ~~删除线~~
下划线 : <u>下划线</u>


  • 无序列表 : - 无序列表
  1. 有序列表 : 1. 有序列表


区块 : > 区块

可以嵌套 : >> 可以嵌套

代码 : `代码`

1
代码段 : \`\`\`代码段\`\`\`(删掉斜杠)

链接 : [链接](网址)
图片

图片 : ![描述](网址), 注意某些网址不适用, 比如csdn

其他html元素
Ctrl : <kbd>Ctrl</kbd>
\ : 转义


f(x)=abf(x)=a-b : $f(x)=a-b$

$\$f(x)=a+b$\$(删掉斜杠) 如下

f(x)=a+bf(x)=a+b


高级公式和矩阵用到了自己去搜
还支持各种流程图

更换hexo默认md渲染器

hexo默认采用hexo-renderer-marked渲染器, 不支持插件, 上述例子中部分不支持, 下面一个一个解决

  • 更换渲染器
    换成支持插件扩展的hexo-renderer-markdown-it, 在hexo项目目录下执行以下命令

    1
    2
    3
    4
    5
    6
    7
    8
    npm un hexo-renderer-marked --save
    npm i hexo-renderer-markdown-it --save
    # 安装emoji插件
    npm install markdown-it-emoji --save
    # 安装数学公式插件
    npm install markdown-it-katex --save
    # 安装待办事项插件
    npm install markdown-it-checkbox --save
  • 编辑hexo项目配置文件
    项目根目录下的_config.yml, 添加以下内容

    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
    # Markdown-it config
    ## Docs: https://github.com/celsomiranda/hexo-renderer-markdown-it/wiki
    markdown:
    render:
    html: true # 是否对HTML标签进行解析,false时HTML将按照原样输出
    xhtmlOut: false # 是否需要满足严格的XHTML格式,换行为<br />
    breaks: true
    linkify: true
    typographer: true
    quotes: '“”‘’'
    plugins:
    - markdown-it-abbr
    - markdown-it-footnote
    - markdown-it-ins
    - markdown-it-sub
    - markdown-it-sup
    - markdown-it-emoji # add emoji
    - markdown-it-katex
    - markdown-it-checkbox
    anchors:
    # Minimum level for ID creation. (Ex. h2 to h6)
    level: 2
    # A suffix that is prepended to the number given if the ID is repeated.
    collisionSuffix: 'v'
    # If `true`, creates an anchor tag with a permalink besides the heading.
    permalink: false
    # Class used for the permalink anchor tag.
    permalinkClass: header-anchor
    # The symbol used to make the permalink
    permalinkSymbol: ¶
  • 另外
    安装数学公式插件, 需要在主题的模板文件中加一行代码, 路径大概在

    1
    themes/next/layout/_partial/head.swig

    加入

    1
    <link href="https://cdn.bootcss.com/KaTeX/0.7.1/katex.min.css" rel="stylesheet">
打赏
  • 版权声明: 本博客所有文章除特别声明外,均采用 Apache License 2.0 许可协议。转载请注明出处!
  • © 2017-2023 王丹鹏
  • Powered by Hexo Theme Ayer
  • 冀ICP备15029707号

请我喝杯咖啡吧~

支付宝
微信