You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This setup function allows you to define custom transformers for the markdown content of **each slide**. This is useful when you want to add custom Markdown syntax and render custom code blocks. To start, create a `./setup/transformers.ts` file with the following content:
function myCodeblock(ctx:MarkdownTransformContext) {
12
+
console.log('index in presentation', ctx.slide.index)
13
+
ctx.s.replace(
14
+
/^```myblock *(\{[^\n]*\})?\n([\s\S]+?)\n```/gm,
15
+
(full, options='', code='') => {
16
+
return`...`
17
+
},
18
+
)
19
+
}
20
+
21
+
exportdefaultdefineTransformersSetup(() => {
22
+
return {
23
+
pre: [],
24
+
preCodeblock: [myCodeblock],
25
+
postCodeblock: [],
26
+
post: [],
27
+
}
28
+
})
29
+
````
30
+
31
+
The return value should be the custom options for the transformers. The `pre`, `preCodeblock`, `postCodeblock`, and `post` are arrays of functions that will be called in order to transform the markdown content. The order of the transformers is:
32
+
33
+
1.`pre` from your project
34
+
2.`pre` from addons and themes
35
+
3. Import snippets syntax and Shiki magic move
36
+
4.`preCodeblock` from your project
37
+
5.`preCodeblock` from addons and themes
38
+
6. Built-in special code blocks like Mermaid, Monaco and PlantUML
39
+
7.`postCodeblock` from addons and themes
40
+
8.`postCodeblock` from your project
41
+
9. Other built-in transformers like code block wrapping
0 commit comments