-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
index.d.ts
158 lines (127 loc) · 3.76 KB
/
index.d.ts
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
declare namespace MarpitEnv {
interface HTMLAsArray {
htmlAsArray: true
[key: string]: any
}
}
declare namespace Marpit {
interface Options {
anchor?: boolean | AnchorCallback
container?: false | Element | Element[]
headingDivider?: false | HeadingDivider | HeadingDivider[]
looseYAML?: boolean
markdown?: any
printable?: boolean
slideContainer?: false | Element | Element[]
inlineSVG?: boolean | InlineSVGOptions
}
type AnchorCallback = (index: number) => string
type HeadingDivider = 1 | 2 | 3 | 4 | 5 | 6
type InlineSVGOptions = {
enabled?: boolean
backdropSelector?: boolean
}
type RenderResult<T = string> = {
html: T
css: string
comments: string[][]
}
type DirectiveDefinitions = {
[directive: string]: (
value: string | object | (string | object)[],
marpit?: Marpit
) => { [meta: string]: any }
}
type Plugin<P extends any[], T extends {} = {}> = (
this: Marpit['markdown'] & T,
md: Marpit['markdown'] & T,
...params: P
) => void
type ThemeReservedMeta = {
theme: string
}
type ThemeMetaType = {
[key: string]: StringConstructor | ArrayConstructor
}
type ThemeOptions = {
metaType?: ThemeMetaType
}
type ThemeSetPackOptions = {
after?: string
before?: string
containers?: Element[]
printable?: boolean
inlineSVG?: boolean
}
type PluginFactory = <P extends any[]>(
plugin: Plugin<P, { marpit: Marpit }>
) => Plugin<P, { marpit: Marpit }>
export class Marpit {
constructor(opts?: Options)
markdown: any
themeSet: ThemeSet
readonly customDirectives: {
global: DirectiveDefinitions
local: DirectiveDefinitions
}
readonly options: Options
protected lastComments: RenderResult['comments'] | undefined
protected lastGlobalDirectives: { [directive: string]: any } | undefined
protected lastSlideTokens: any[] | undefined
protected lastStyles: string[] | undefined
render(markdown: string, env: MarpitEnv.HTMLAsArray): RenderResult<string[]>
render(markdown: string, env?: any): RenderResult
use<P extends any[]>(plugin: Plugin<P>, ...params: P): this
protected applyMarkdownItPlugins(md: any): void
protected renderMarkdown(markdown: string, env?: any): string
protected renderStyle(theme?: string): string
protected themeSetPackOptions(): ThemeSetPackOptions
}
export class Element {
constructor(tag: string, attributes?: {})
[index: string]: any
tag: string
}
export class Theme {
protected constructor(name: string, css: string)
static fromCSS(cssString: string, opts?: ThemeOptions): Readonly<Theme>
css: string
height: string
importRules: {
node: any
value: string
}[]
meta: Readonly<ThemeReservedMeta & Record<string, string | string[]>>
name: string
width: string
readonly heightPixel: number | undefined
readonly widthPixel: number | undefined
}
export class ThemeSet {
constructor()
default: Theme | undefined
metaType: ThemeMetaType
readonly size: number
private readonly themeMap: Map<string, Theme>
add(css: string): Theme
addTheme(theme: Theme): void
clear(): void
delete(name: string): boolean
get(name: string, fallback?: boolean): Theme | undefined
getThemeMeta(
theme: string | Theme,
meta: string
): string | string[] | undefined
getThemeProp(theme: string | Theme, prop: string): any
has(name: string): boolean
pack(name: string, opts: ThemeSetPackOptions): string
themes(): IterableIterator<Theme>
}
}
declare module '@marp-team/marpit' {
export = Marpit
}
declare module '@marp-team/marpit/plugin' {
export const marpitPlugin: Marpit.PluginFactory
export default marpitPlugin
}