返回 slidev
prettier-plugin.md
根目录 / docs / features / prettier-plugin.md
1 ---
2 relates:
3 - features/block-frontmatter
4 - GitHub Repo: https://github.com/slidevjs/prettier-plugin
5 - Prettier: https://prettier.io/
6 tags: [editor]
7 description: |
8 Use the Prettier plugin to format your slides.
9 ---
10
11 # Prettier Plugin
12
13 The Slidev's syntax may be incompatible with the default Markdown parser of [Prettier](https://prettier.io/). To solve this, Slidev provides a Prettier plugin to format your slides. You can use it with your favorite editor that supports Prettier.
14
15 ## 1. Install
16
17 ::: code-group
18
19 ```bash [npm]
20 npm i -D prettier prettier-plugin-slidev
21 ```
22
23 ```bash [pnpm]
24 pnpm i -D prettier prettier-plugin-slidev
25 ```
26
27 ```bash [yarn]
28 yarn add -D prettier prettier-plugin-slidev
29 ```
30
31 ```bash [bun]
32 bun add -D prettier prettier-plugin-slidev
33 ```
34
35 ```bash [deno]
36 deno add -D npm:prettier npm:prettier-plugin-slidev
37 ```
38
39 :::
40
41 ## 2. Activate the plugin
42
43 Create or modify your [prettier configuration file](https://prettier.io/docs/en/configuration) to activate the plugin:
44
45 ```json
46 {
47 "overrides": [
48 {
49 "files": ["slides.md", "pages/*.md"],
50 "options": {
51 "parser": "slidev",
52 "plugins": ["prettier-plugin-slidev"]
53 }
54 }
55 ]
56 }
57 ```
58
59 Note that only specifying `plugins` is not enough, because Slidev and common Markdown files share the same file extension `.md`.
60
60 lines MARKDOWN