docsify-docs-cn/markdown.md
Yan Chen e6a603808c
Update the ALL chinese doc translation to v4.11.3 . (#19)
* Update some translate to 4.11.3 version.

* Update more docs to chinese.

* update the all document to v4.11.3 chinese.

* Update README.md

* Update cdn.md

* Update configuration.md

* Update cover.md

* Update custom-navbar.md

* Update deploy.md

* Update deploy.md

* Update embed-files.md

* Update plugins.md

* PR modify request modified.

* delete an extra line.

* delete an extra line.

* Update deploy.md

Co-authored-by: Luffy <52o@qq52o.cn>
2020-04-26 13:54:44 +08:00

1.1 KiB

Markdown 配置

内置的 Markdown 解析器是 marked,可以修改它的配置。同时可以直接配置 renderer

window.$docsify = {
  markdown: {
    smartypants: true,
    renderer: {
      link: function() {
        // ...
      }
    }
  }
}

?> 完整配置参数参考 marked 文档

当然也可以完全定制 Markdown 解析规则。

window.$docsify = {
  markdown: function(marked, renderer) {
    // ...

    return marked
  }
}

支持 mermaid

// Import mermaid
//  <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.css">
//  <script src="//cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>

var num = 0;
mermaid.initialize({ startOnLoad: false });

window.$docsify = {
  markdown: {
    renderer: {
      code: function(code, lang) {
        if (lang === "mermaid") {
          return (
            '<div class="mermaid">' + mermaid.render('mermaid-svg-' + num++, code) + "</div>"
          );
        }
        return this.origin.code.apply(this, arguments);
      }
    }
  }
}