Skip to content

Commit ee683ae

Browse files
authored
docs: explain mode parameter for preparser extensions (#176)
1 parent e805422 commit ee683ae

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: custom/config-parser.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Configuring the markdown parser used in step 2 can be done by [configuring Vite
1212

1313
## Preparser Extensions
1414

15-
> Available since v0.37.0
15+
> Available since v0.37.0.
1616
1717
:::warning
1818
Important: when modifying the preparser configuration, you need to stop and start slidev again (restart might not be sufficient).
@@ -25,7 +25,7 @@ To customize it, create a `./setup/preparser.ts` file with the following content
2525
```ts
2626
import { definePreparserSetup } from '@slidev/types'
2727

28-
export default definePreparserSetup(({ filepath, headmatter }) => {
28+
export default definePreparserSetup(({ filepath, headmatter, mode }) => {
2929
return [
3030
{
3131
transformRawLines(lines) {
@@ -41,7 +41,7 @@ export default definePreparserSetup(({ filepath, headmatter }) => {
4141

4242
This example systematically replaces any `@@@` line by a line with `hello`. It illustrates the structure of a preparser configuration file and some of the main concepts the preparser involves:
4343
- `definePreparserSetup` must be called with a function as parameter.
44-
- The function receives the file path (of the root presentation file) and headmatter (from the md file). It could use this information (e.g., enable extensions based on the presentation file).
44+
- The function receives the file path (of the root presentation file), the headmatter (from the md file) and, since v0.48.0, a mode (dev, build or export). It could use this information (e.g., enable extensions based on the presentation file or whether we are exporting a PDF).
4545
- The function must return a list of preparser extensions.
4646
- An extension can contain:
4747
- a `transformRawLines(lines)` function that runs just after parsing the headmatter of the md file and receives a list of all lines (from the md file). The function can mutate the list arbitrarily.

0 commit comments

Comments
 (0)