Repository navigation
Expand file tree
/
Copy pathindex.ts
More file actions
71 lines (64 loc) · 1.85 KB
/
Copy pathindex.ts
File metadata and controls
71 lines (64 loc) · 1.85 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import type MarkdownIt from 'markdown-it'
import type { MdcInlineSpanOptions } from './syntax/inline-span'
import { MarkdownItMdcBlock } from './syntax/block'
import { MarkdownItInlineComponent } from './syntax/inline-component'
import { MarkdownItInlineProps } from './syntax/inline-props'
import { MarkdownItInlineSpan } from './syntax/inline-span'
export interface MarkdownItMdcOptions {
/**
* Options for toggling each syntax feature.
*/
syntax?: {
/**
* Enable block component syntax.
*
* @see https://content.nuxtjs.org/guide/writing/mdc#block-components
* @default true
*/
blockComponent?: boolean
/**
* Enable inline props syntax.
*
* @see https://content.nuxtjs.org/guide/writing/mdc#inline-props
* @default true
*/
inlineProps?: boolean
/**
* Enable inline span syntax.
*
* Pass `true` to enable with defaults, or pass an object to configure.
*
* @see https://content.nuxtjs.org/guide/writing/mdc#inline-span
* @default true
*/
inlineSpan?: boolean | MdcInlineSpanOptions
/**
* Enable inline component syntax.
*
* @see https://content.nuxtjs.org/guide/writing/mdc#inline-component
* @default true
*/
inlineComponent?: boolean
}
}
const MarkdownItMdc: MarkdownIt.PluginWithOptions<MarkdownItMdcOptions> = (md, options = {}) => {
const {
blockComponent = true,
inlineProps = true,
inlineSpan = true,
inlineComponent = true,
} = options.syntax || {}
if (blockComponent)
md.use(MarkdownItMdcBlock)
if (inlineProps)
md.use(MarkdownItInlineProps)
if (inlineSpan) {
const spanOptions = typeof inlineSpan === 'object'
? inlineSpan
: {}
md.use(MarkdownItInlineSpan, spanOptions)
}
if (inlineComponent)
md.use(MarkdownItInlineComponent)
}
export default MarkdownItMdc