2017-02-13 22:43:58 +08:00
# Markdown configuration
2018-08-08 10:16:32 +08:00
**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` :
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
markdown: {
2017-02-19 00:11:16 +08:00
smartypants: true,
renderer: {
2023-07-03 16:27:22 +08:00
link() {
2017-02-19 00:11:16 +08:00
// ...
2023-08-09 17:53:30 +08:00
},
},
},
};
2017-02-13 22:43:58 +08:00
```
2021-07-30 10:18:00 +08:00
?> Configuration Options Reference: [marked documentation ](https://marked.js.org/#/USING_ADVANCED.md )
2017-02-13 22:43:58 +08:00
2021-07-30 10:18:00 +08:00
You can completely customize the parsing rules.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
2023-07-03 16:27:22 +08:00
markdown(marked, renderer) {
2017-02-13 22:43:58 +08:00
// ...
2023-08-09 17:53:30 +08:00
return marked;
},
};
2017-02-13 22:43:58 +08:00
```
2017-08-17 16:52:54 +08:00
## Supports mermaid
```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 >
2023-07-03 16:27:22 +08:00
let num = 0;
2017-08-17 17:18:41 +08:00
mermaid.initialize({ startOnLoad: false });
2017-08-17 16:52:54 +08:00
window.$docsify = {
markdown: {
renderer: {
2023-07-03 16:27:22 +08:00
code(code, lang) {
2023-08-09 17:53:30 +08:00
if (lang === 'mermaid') {
2023-07-03 16:27:22 +08:00
return /* html */ `
2023-08-09 17:53:30 +08:00
< div class = "mermaid" > ${mermaid.render(
'mermaid-svg-' + num++,
code
)}< / div >
2023-07-03 16:27:22 +08:00
`;
2017-08-17 16:52:54 +08:00
}
return this.origin.code.apply(this, arguments);
2023-08-09 17:53:30 +08:00
},
},
},
};
2017-08-17 16:52:54 +08:00
```