-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathindex.js
38 lines (34 loc) · 1.32 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import MarkdownIt from 'markdown-it'
import taskLists from '@hedgedoc/markdown-it-task-lists'
import markdownitMentions from '@quartzy/markdown-it-mentions'
import underline from './underline.js'
import splitMixedLists from './splitMixedLists.js'
import callouts from './callouts.js'
import hardbreak from './hardbreak.js'
import keepSyntax from './keepSyntax.js'
import frontMatter from 'markdown-it-front-matter'
import implicitFigures from 'markdown-it-image-figures'
import { escapeHtml } from 'markdown-it/lib/common/utils.js'
const markdownit = MarkdownIt('commonmark', { html: false, breaks: false })
.enable('strikethrough')
.enable('table')
.use(taskLists, { enable: true, labelAfter: true })
.use(frontMatter, (fm) => {})
.use(splitMixedLists)
.use(underline)
.use(hardbreak)
.use(callouts)
.use(keepSyntax)
.use(markdownitMentions)
.use(implicitFigures)
// Render front matter tokens
markdownit.renderer.rules.front_matter = (tokens, idx, options) => `<pre id="frontmatter"><code>${escapeHtml(tokens[idx].meta)}</code></pre>`
// Render lists with bullet attribute
markdownit.renderer.rules.bullet_list_open = (tokens, idx, options) => {
tokens[idx].attrs = [
...(tokens[idx].attrs || []),
['data-bullet', tokens[idx].markup],
]
return markdownit.renderer.renderToken(tokens, idx, options)
}
export default markdownit