-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
definitions.ts
381 lines (338 loc) · 13 KB
/
definitions.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
import dedent from 'dedent'
import { MarkdownString } from 'vscode'
export enum DirectiveType {
Global = 'Global',
Local = 'Local',
}
export enum DirectiveDefinedIn {
FrontMatter = 'frontMatter',
Comment = 'comment',
}
const directiveAlwaysAllowed = [
DirectiveDefinedIn.FrontMatter,
DirectiveDefinedIn.Comment,
] as const
export enum DirectiveProvidedBy {
Marpit = 'Marpit framework',
MarpCore = 'Marp Core',
MarpCLI = 'Marp CLI',
MarpVSCode = 'Marp for VS Code',
}
interface DirectiveInfoBase {
allowed: readonly DirectiveDefinedIn[]
completable?: boolean
description: string
details?: string
markdownDescription: MarkdownString
markdownDetails: MarkdownString
name: string
providedBy: DirectiveProvidedBy
type: DirectiveType
}
export type GlobalDirectiveInfo = DirectiveInfoBase & {
scoped?: never
type: DirectiveType.Global
}
export type LocalDirectiveInfo = DirectiveInfoBase & {
scoped?: boolean
type: DirectiveType.Local
}
export type DirectiveInfo = GlobalDirectiveInfo | LocalDirectiveInfo
export const createDirectiveInfo = (
info:
| Omit<GlobalDirectiveInfo, 'markdownDescription' | 'markdownDetails'>
| Omit<LocalDirectiveInfo, 'markdownDescription' | 'markdownDetails'>,
): Readonly<DirectiveInfo> => {
const directiveText = `\`${info.name}\` [${
info.type
} directive](https://marpit.marp.app/directives?id=${info.type.toLowerCase()}-directives)${
info.scoped ? ' _[Scoped]_' : ''
}`
const mdDetails = `_Provided by ${info.providedBy}${
info.details ? ` ([See more details...](${info.details}))` : ''
}_`
return Object.freeze({
...info,
markdownDetails: new MarkdownString(mdDetails),
markdownDescription: new MarkdownString(
[directiveText, info.description, mdDetails].join('\n\n---\n\n'),
true,
),
})
}
export const builtinDirectives = [
// Marp for VS Code
createDirectiveInfo({
name: 'marp',
description: 'Set whether or not enable Marp feature in VS Code.',
allowed: [DirectiveDefinedIn.FrontMatter],
providedBy: DirectiveProvidedBy.MarpVSCode,
type: DirectiveType.Global,
details: 'https://github.com/marp-team/marp-vscode#usage',
}),
// Marpit global directives
createDirectiveInfo({
name: 'theme',
description: dedent(`
Set a theme name of the slide deck.
You can choose from [Marp Core built-in themes](https://github.com/marp-team/marp-core/tree/main/themes) or registered custom themes.
`),
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.Marpit,
type: DirectiveType.Global,
details: 'https://marpit.marp.app/directives?id=theme',
completable: true,
}),
createDirectiveInfo({
name: 'style',
description: dedent(`
Specify CSS for tweaking theme.
It is exactly same as defining inline style within Markdown. Useful if \`<style>\` would break the view in the other Markdown tools.
\`\`\`yaml
style: |
section {
background-color: #123;
color: #def;
}
\`\`\`
`),
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.Marpit,
type: DirectiveType.Global,
details: 'https://marpit.marp.app/directives?id=tweak-theme-style',
}),
createDirectiveInfo({
name: 'headingDivider',
description: dedent(`
Specify heading divider option.
You may instruct to divide slide pages at before of headings automatically. It is useful for making slide from existing Markdown document.
It have to specify heading level from 1 to 6, or array of them. This feature is enabled at headings having the level _higher than or equal to the specified value_ if in a number, and it is enabled at _only specified levels_ if in array.
\`\`\`yaml
# Divide pages by headings having level 3 and higher (#, ##, ###)
headingDivider: 3
# Divide pages by only headings having level 1 and 3 (#, ###)
headingDivider: [1, 3]
\`\`\`
`),
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.Marpit,
type: DirectiveType.Global,
details: 'https://marpit.marp.app/directives?id=heading-divider',
}),
// Marpit local directives
createDirectiveInfo({
name: 'paginate',
description: dedent(`
Control the slide page number.
Use the boolean values \`true\` and \`false\` to control the visibility of the page number on the slide.
You can also manage the page number increment behavior using the additional keywords \`skip\` and \`hold\`.
- \`false\`: Hide the page number. (default)
- \`true\`: Show the page number.
- \`skip\`: Hide the page number and prevent its increment.
- \`hold\`: Show the page number, but prevent increment even on the following page(s).
`),
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.Marpit,
type: DirectiveType.Local,
details: 'https://marpit.marp.app/directives?id=pagination',
completable: true,
}),
createDirectiveInfo({
name: 'header',
description: dedent(`
Set the content of slide header.
The content of header can use basic Markdown formatting. To prevent the broken parsing by YAML special characters, recommend to wrap by quotes \`"\` or \`'\` when used Markdown syntax:
\`\`\`yaml
header: "**Header content**"
\`\`\`
To clear the header content in the middle of slides, set an empty string:
\`\`\`yaml
header: ""
\`\`\`
`),
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.Marpit,
type: DirectiveType.Local,
details: 'https://marpit.marp.app/directives?id=header-and-footer',
}),
createDirectiveInfo({
name: 'footer',
description: dedent(`
Set the content of slide footer.
The content of footer can use basic Markdown formatting. To prevent the broken parsing by YAML special characters, recommend to wrap by quotes \`"\` or \`'\` when used Markdown syntax:
\`\`\`yaml
footer: "**Footer content**"
\`\`\`
To clear the footer content in the middle of slides, set an empty string:
\`\`\`yaml
footer: ""
\`\`\`
`),
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.Marpit,
type: DirectiveType.Local,
details: 'https://marpit.marp.app/directives?id=header-and-footer',
}),
createDirectiveInfo({
name: 'class',
description:
'Set [HTML `class` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class) for the slide element `<section>`.',
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.Marpit,
type: DirectiveType.Local,
details: 'https://marpit.marp.app/directives?id=class',
}),
createDirectiveInfo({
name: 'backgroundColor',
description:
'Set [`background-color` style](https://developer.mozilla.org/en-US/docs/Web/CSS/background-color) of the slide.',
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.Marpit,
type: DirectiveType.Local,
details: 'https://marpit.marp.app/directives?id=backgrounds',
}),
createDirectiveInfo({
name: 'backgroundImage',
description:
'Set [`background-image` style](https://developer.mozilla.org/en-US/docs/Web/CSS/background-image) of the slide.',
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.Marpit,
type: DirectiveType.Local,
details: 'https://marpit.marp.app/directives?id=backgrounds',
}),
createDirectiveInfo({
name: 'backgroundPosition',
description:
'Set [`background-position` style](https://developer.mozilla.org/en-US/docs/Web/CSS/background-position) of the slide.',
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.Marpit,
type: DirectiveType.Local,
details: 'https://marpit.marp.app/directives?id=backgrounds',
}),
createDirectiveInfo({
name: 'backgroundRepeat',
description:
'Set [`background-repeat` style](https://developer.mozilla.org/en-US/docs/Web/CSS/background-repeat) of the slide.',
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.Marpit,
type: DirectiveType.Local,
details: 'https://marpit.marp.app/directives?id=backgrounds',
}),
createDirectiveInfo({
name: 'backgroundSize',
description:
'Set [`background-size` style](https://developer.mozilla.org/en-US/docs/Web/CSS/background-size) of the slide.',
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.Marpit,
type: DirectiveType.Local,
details: 'https://marpit.marp.app/directives?id=backgrounds',
}),
createDirectiveInfo({
name: 'color',
description:
'Set [`color` style](https://developer.mozilla.org/en-US/docs/Web/CSS/color) of the slide.',
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.Marpit,
type: DirectiveType.Local,
details: 'https://marpit.marp.app/directives?id=backgrounds',
}),
// Marp Core extension
createDirectiveInfo({
name: 'math',
description: dedent(`
Choose a library to render math typesetting in the current Markdown.
- \`mathjax\`: Use [MathJax](https://www.mathjax.org/).
- \`katex\`: Use [KaTeX](https://katex.org/).
Marp may change the default library of the ecosystem in the future. To prevent breaking existing slides, recommend to declare used library whenever to use math typesetting.
`),
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.MarpCore,
type: DirectiveType.Global,
details: 'https://github.com/marp-team/marp-core#math-global-directive',
completable: true,
}),
createDirectiveInfo({
name: 'size',
description: dedent(`
Choose the slide size preset provided by theme.
Accepted presets are depending on using theme. In the case of Marp Core built-in theme, you can choose from \`16:9\` (1280x720) or \`4:3\` (960x720).
`),
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.MarpCore,
type: DirectiveType.Global,
details: 'https://github.com/marp-team/marp-core#size-global-directive',
completable: true,
}),
// Marp CLI metadata options
createDirectiveInfo({
name: 'title',
description: 'Set title of the slide deck.',
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.MarpCLI,
type: DirectiveType.Global,
details: 'https://github.com/marp-team/marp-cli#metadata',
}),
createDirectiveInfo({
name: 'description',
description: 'Set description of the slide deck.',
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.MarpCLI,
type: DirectiveType.Global,
details: 'https://github.com/marp-team/marp-cli#metadata',
}),
createDirectiveInfo({
name: 'author',
description: 'Set author of the slide deck.',
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.MarpCLI,
type: DirectiveType.Global,
details: 'https://github.com/marp-team/marp-cli#metadata',
}),
createDirectiveInfo({
name: 'keywords',
description:
'Set keywords for the slide deck. It accepts a string consisted by comma-separated keywords, or YAML array of keywords.',
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.MarpCLI,
type: DirectiveType.Global,
details: 'https://github.com/marp-team/marp-cli#metadata',
}),
createDirectiveInfo({
name: 'url',
description: 'Set canonical URL for the slide deck.',
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.MarpCLI,
type: DirectiveType.Global,
details: 'https://github.com/marp-team/marp-cli#metadata',
}),
createDirectiveInfo({
name: 'image',
description: 'Set Open Graph image URL.',
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.MarpCLI,
type: DirectiveType.Global,
details: 'https://github.com/marp-team/marp-cli#metadata',
}),
// Marp CLI transitions for bespoke template
createDirectiveInfo({
name: 'transition',
description: dedent(`
Set the slide transition effect to the next page boundary.
When viewing the HTML slide deck in a browser that supports the [View Transitions API](https://www.w3.org/TR/css-view-transitions-1/), the animation of the specified effect will be visible when navigating the presentation.
You can choose the effect from [33 built-in transitions in Marp CLI](https://github.com/marp-team/marp-cli/blob/main/docs/bespoke-transitions/README.md#built-in-transitions), or [the custom transition effects defined in CSS](https://github.com/marp-team/marp-cli/blob/main/docs/bespoke-transitions/README.md#custom-transitions).
\`\`\`yaml
transition: fade
\`\`\`
You can also set the custom duration of the specified effect with a space-separated parameter.
\`\`\`yaml
transition: fade 1s
\`\`\`
`),
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.MarpCLI,
type: DirectiveType.Local,
details:
'https://github.com/marp-team/marp-cli/blob/main/docs/bespoke-transitions/README.md',
completable: true,
}),
] as const