docs: correct mermaid docs after upgrade marked (#2490)

---------

Co-authored-by: Luffy <52o@qq52o.cn>
This commit is contained in:
Koy Zhuang 2024-08-18 20:18:41 +08:00 committed by GitHub
parent 87b568308a
commit e204ac669d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,6 @@
# Markdown configuration
**docsify** uses [marked](https://github.com/markedjs/marked) as its Markdown parser. You can customize how it renders your Markdown content to HTML by customizing `renderer`:
**docsify** uses [marked v13+](https://github.com/markedjs/marked) as its Markdown parser. You can customize how it renders your Markdown content to HTML by customizing `renderer`:
```js
window.$docsify = {
@ -31,10 +31,11 @@ window.$docsify = {
## Supports mermaid
!> Currently, docsify doesn't support the async mermaid render (the latest mermaid version supported is `v9.3.0`).
```js
// 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>
// <script src="//cdn.jsdelivr.net/npm/mermaid@9.3.0/dist/mermaid.min.js"></script>
let num = 0;
mermaid.initialize({ startOnLoad: false });
@ -42,12 +43,12 @@ mermaid.initialize({ startOnLoad: false });
window.$docsify = {
markdown: {
renderer: {
code(code, lang) {
code({ text, lang }) {
if (lang === 'mermaid') {
return /* html */ `
<div class="mermaid">${mermaid.render(
'mermaid-svg-' + num++,
code,
text,
)}</div>
`;
}