https://github.com/tylingsoft/markdown-it-mermaid
Mermaid plugin for markdown-it.
https://github.com/tylingsoft/markdown-it-mermaid
Last synced: about 1 year ago
JSON representation
Mermaid plugin for markdown-it.
- Host: GitHub
- URL: https://github.com/tylingsoft/markdown-it-mermaid
- Owner: tylingsoft
- Created: 2017-04-01T12:43:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-12-27T05:23:56.000Z (over 7 years ago)
- Last Synced: 2025-03-28T07:16:39.041Z (over 1 year ago)
- Language: JavaScript
- Size: 164 KB
- Stars: 43
- Watchers: 5
- Forks: 45
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# markdown-it-mermaid
Mermaid plugin for markdown-it.
## Installation
```
yarn install markdown-it-mermaid
```
## Usage
```js
import markdownIt from 'markdown-it'
import markdownItMermaid from 'markdown-it-mermaid'
const mdi = markdownIt()
mdi.use(markdownItMermaid)
mdi.render(`\`\`\`mermaid
graph TD
A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[Car]
\`\`\``)
```
### Customize mermaid
```js
mdi.mermaid.loadPreferences({
get: key => {
if (key === 'mermaid-theme') {
return 'forest'
} else if (key === 'gantt-axis-format') {
return '%Y/%m/%d'
} else {
return undefined
}
}
})
```
You can `loadPreferences` from any preferences store as long as it supports the `get` method. For example, you can use `js-cookie` library as a preferences store. Or you can write your own preferences store to achieve more flexibility.
`mdi.mermaid.loadPreferences` not only applies the preferences, it also return the preferences loaded. Just in case you need to access the loaded preferences.
`mdi.mermaid.loadPreferences` could be invoked multiple times. And the preferences applied later will override ones applied earlier.
## Development
### Build
```
yarn build:watch
```
### Test
```
yarn test
```
### Distribution
```
yarn release && npm publish
```
## Todo
`gantt-axis-format` should support large date ranges