docsify/docs/markdown.md

56 lines
1.2 KiB
Markdown
Raw Normal View History

2017-02-13 22:43:58 +08:00
# Markdown configuration
2017-03-10 05:19:07 +08:00
**docsify** uses [marked](https://github.com/chjj/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: {
link: function() {
// ...
}
}
2017-02-13 22:43:58 +08:00
}
}
```
?> Configuration Options Reference [marked documentation](https://github.com/chjj/marked#options-1)
Even you can completely customize the parsing rules.
```js
window.$docsify = {
markdown: function(marked, renderer) {
// ...
return marked
}
}
```
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>
2017-08-17 17:18:41 +08:00
mermaid.initialize({ startOnLoad: false });
2017-08-17 16:52:54 +08:00
window.$docsify = {
markdown: {
renderer: {
code: function(code, lang) {
if (lang === "mermaid") {
return (
'<div class="mermaid">' + mermaid.render(lang, code) + "</div>"
);
}
return this.origin.code.apply(this, arguments);
}
}
}
}
```