prettier-plugin-embed 0.4.10 → 0.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +578 -89
- package/dist/embedded/css/options.d.ts +36 -11
- package/dist/embedded/es/options.d.ts +36 -11
- package/dist/embedded/glsl/options.d.ts +36 -11
- package/dist/embedded/graphql/options.d.ts +36 -10
- package/dist/embedded/html/options.d.ts +36 -11
- package/dist/embedded/index.d.ts +2 -2
- package/dist/embedded/ini/options.d.ts +36 -10
- package/dist/embedded/java/options.d.ts +36 -5
- package/dist/embedded/json/options.d.ts +37 -11
- package/dist/embedded/jsonata/options.d.ts +36 -5
- package/dist/embedded/latex/options.d.ts +36 -10
- package/dist/embedded/markdown/options.d.ts +36 -11
- package/dist/embedded/nginx/options.d.ts +36 -5
- package/dist/embedded/noop/options.d.ts +29 -3
- package/dist/embedded/pegjs/options.d.ts +36 -5
- package/dist/embedded/php/options.d.ts +36 -11
- package/dist/embedded/prisma/options.d.ts +36 -5
- package/dist/embedded/properties/options.d.ts +36 -10
- package/dist/embedded/pug/options.d.ts +36 -5
- package/dist/embedded/ruby/options.d.ts +36 -10
- package/dist/embedded/sh/options.d.ts +36 -10
- package/dist/embedded/sql/options.d.ts +36 -11
- package/dist/embedded/toml/options.d.ts +36 -10
- package/dist/embedded/ts/options.d.ts +37 -12
- package/dist/embedded/types.d.ts +8 -2
- package/dist/embedded/utils.d.ts +3 -1
- package/dist/embedded/xml/options.d.ts +36 -11
- package/dist/embedded/yaml/options.d.ts +36 -10
- package/dist/index.js +1537 -1068
- package/dist/options.d.ts +509 -11
- package/dist/types.d.ts +36 -6
- package/dist/utils.d.ts +136 -5
- package/package.json +5 -6
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
[](https://github.com/Sec-ant/prettier-plugin-embed) [](https://bundlephobia.com/package/prettier-plugin-embed@latest) [](https://www.jsdelivr.com/package/npm/prettier-plugin-embed)
|
|
10
10
|
|
|
11
|
-
A
|
|
11
|
+
A configurable [Prettier](https://prettier.io/) [plugin](https://prettier.io/docs/en/plugins.html) to format [embedded languages](https://prettier.io/docs/en/options.html#embedded-language-formatting) in JS/TS Files.
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
npm i -D prettier-plugin-embed
|
|
@@ -24,7 +24,7 @@ This Prettier plugin (namely [`prettier-plugin-embed`](https://github.com/Sec-an
|
|
|
24
24
|
|
|
25
25
|
### Why?
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
Prettier has introduced an option for formatting embedded languages, named [`embedded-language-formatting`](https://prettier.io/docs/en/options.html#embedded-language-formatting). However, this option only offers two modes: `auto` and `off`. This limits its functionality, as it does not permit individual formatting adjustments for specific languages. Additionally, it lacks support for customizing which languages require formatting, as well as specifying block comments or tags for embedded language identification. These constraints hinder the feature's overall usability. For in-depth discussions on this matter, see the GitHub issues: [prettier/prettier#4424](https://github.com/prettier/prettier/issues/4424) and [prettier/prettier#5588](https://github.com/prettier/prettier/issues/5588).
|
|
28
28
|
|
|
29
29
|
### How?
|
|
30
30
|
|
|
@@ -34,15 +34,15 @@ By leveraging Prettier's plugin system, this plugin overrides the default [`embe
|
|
|
34
34
|
|
|
35
35
|
- **Support for Additional Languages:** Extend the embedded language formatting capability to include languages such as XML, SQL, PHP, and more.
|
|
36
36
|
|
|
37
|
-
- **Dual Identification Modes:** Identify embedded languages by
|
|
37
|
+
- **Dual Identification Modes:** Identify embedded languages by block comments `` /* comment */ `...` `` or tags `` tag`...` `` preceding the template literals.
|
|
38
38
|
|
|
39
|
-
- **Customizable Language
|
|
39
|
+
- **Customizable Language Comments or Tags:** Customize the comments or tags used for identifying the embedded languages.
|
|
40
40
|
|
|
41
|
-
- **Formatting Opt-out Mechanism:** Offer the capability to deactivate formatting for certain
|
|
41
|
+
- **Formatting Opt-out Mechanism:** Offer the capability to deactivate formatting for certain comments or tags, including the built-in ones (`html`, `css`...) supported by the `embedded-language-formatting` option.
|
|
42
42
|
|
|
43
43
|
- **Configurable Formatting Style:** Provide additional options to tailor the formatting style for embedded languages.
|
|
44
44
|
|
|
45
|
-
- **Strongly Typed API:** Benefit from comprehensive type support for configuring this plugin's options
|
|
45
|
+
- **Strongly Typed API:** Benefit from comprehensive type support for configuring this plugin's options.
|
|
46
46
|
|
|
47
47
|
- **Easy Integration:** Integrate with the existing Prettier setup seamlessly, requiring minimal configuration to get started.
|
|
48
48
|
|
|
@@ -93,17 +93,17 @@ Here're some [quick start config examples](./ConfigExamples.md) to use this plug
|
|
|
93
93
|
|
|
94
94
|
To use this plugin, [`embedded-language-formatting`](https://prettier.io/docs/en/options.html#embedded-language-formatting) option must be set to `auto` (which is the default setting as of now), because this option serves as the main switch for activating embedded language formatting.
|
|
95
95
|
|
|
96
|
-
This plugin does not aim to implement parsers or printers to support every newly added embedded language.
|
|
96
|
+
This plugin does not aim to implement parsers or printers to support every newly added embedded language. Rather, it aims to leverage existing [Prettier plugins](https://prettier.io/docs/en/plugins.html#official-plugins) for those languages, and only adds a thin layer of formatting support when they are embedded in template literals.
|
|
97
97
|
|
|
98
98
|
Therefore, to enable formatting for a specific embedded language, the corresponding Prettier plugin for that language must also be loaded. For example, if you wish to format embedded XML language, you will need to load both this plugin and [`@prettier/plugin-xml`](https://github.com/prettier/plugin-xml). To find out which other plugins are required when using this plugin, please refer to the [Language-Specific Options](#language-specific-options) section below.
|
|
99
99
|
|
|
100
|
-
Embedded languages to be formatted are required to be enclosed in the template literals, and are identified by the preceding [
|
|
100
|
+
Embedded languages to be formatted are required to be enclosed in the template literals, and are identified by the preceding [block comments](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#block_comments) `` /* comment */ `...` `` or [tags](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) `` tag`...` ``. This plugin comes pre-configured with a built-in set of comments and tags for identifying various embedded languages. For instance, using comments like `/* xml */` or `/* svg */` or tags like `xml` or `svg` will trigger automatic formatting for the embedded XML language. You can specify an alternative list of comments or tags using the `embeddedXmlComments` option or the `embeddedXmlTags` option, respectively. The naming convention for these options follows the pattern of `embedded<Language>Comments` and `embedded<Language>Tags` for other languages as well. Further details on these options and how to configure them are also available in the [Language-Specific Options](#language-specific-options) section.
|
|
101
101
|
|
|
102
|
-
To exclude certain
|
|
102
|
+
To exclude certain comments or tags from being identified, like the default ones supported by the [`embedded-language-formatting`](https://prettier.io/docs/en/options.html#embedded-language-formatting) option, add them to the list of the `embeddedNoopComments`/`embeddedNoopTags` options. Any matching comments or tags listed in these options will take precedence over other `embedded<Language>Comments` and `embedded<Language>Tags` options, effectively disabling their formatting.
|
|
103
103
|
|
|
104
104
|
> [!IMPORTANT]
|
|
105
105
|
>
|
|
106
|
-
> Until this notice is removed, always specify
|
|
106
|
+
> Until this notice is removed, always specify comments or tags explicitly and do not rely on the built-in defaults, as they may be subject to change.
|
|
107
107
|
|
|
108
108
|
### Language-Specific Options
|
|
109
109
|
|
|
@@ -141,21 +141,59 @@ Click Here to Toggle
|
|
|
141
141
|
|
|
142
142
|
#### NOOP
|
|
143
143
|
|
|
144
|
-
##### `
|
|
144
|
+
##### `embeddedNoopComments`
|
|
145
145
|
|
|
146
146
|
- **Type**: `string[]`
|
|
147
147
|
- **Default**: [`[]`](./src/embedded/noop/options.ts)
|
|
148
|
-
- **Description**:
|
|
148
|
+
- **Description**: Block comments that prevent their subsequent template literals from being identified as embedded languages and thus from being formatted.
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
##### `embeddedNoopTags`
|
|
151
|
+
|
|
152
|
+
- **Type**: `string[]`
|
|
153
|
+
- **Default**: [`[]`](./src/embedded/noop/options.ts)
|
|
154
|
+
- **Description**: Tags that prevent their subsequent template literals from being identified as embedded languages and thus from being formatted.
|
|
155
|
+
|
|
156
|
+
##### ~~`embeddedNoopIdentifiers`~~
|
|
157
|
+
|
|
158
|
+
<details>
|
|
159
|
+
<summary>deprecated</summary>
|
|
160
|
+
|
|
161
|
+
- **Type**: `string[]`
|
|
162
|
+
- **Default**: [`[]`](./src/embedded/noop/options.ts)
|
|
163
|
+
- **Description**: Comment or tag identifiers that prevent their subsequent template literals from being identified as embedded languages and thus from being formatted.
|
|
164
|
+
|
|
165
|
+
Please use `embeddedNoopComments` or `embeddedNoopTags`.
|
|
166
|
+
|
|
167
|
+
</details>
|
|
168
|
+
|
|
169
|
+
This "language" doesn't require other plugins and can override the native embedded language formatting. It serves as a way to turn off embedded language formatting for the specified language comments or tags.
|
|
151
170
|
|
|
152
171
|
#### CSS
|
|
153
172
|
|
|
154
|
-
##### `
|
|
173
|
+
##### `embeddedCssComments`
|
|
174
|
+
|
|
175
|
+
- **Type**: `string[]`
|
|
176
|
+
- **Default**: [`["css"]`](./src/embedded/css/options.ts)
|
|
177
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded CSS language.
|
|
178
|
+
|
|
179
|
+
##### `embeddedCssTags`
|
|
155
180
|
|
|
156
181
|
- **Type**: `string[]`
|
|
157
182
|
- **Default**: [`["css"]`](./src/embedded/css/options.ts)
|
|
158
|
-
- **Description**:
|
|
183
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded CSS language.
|
|
184
|
+
|
|
185
|
+
##### ~~`embeddedCssIdentifiers`~~
|
|
186
|
+
|
|
187
|
+
<details>
|
|
188
|
+
<summary>deprecated</summary>
|
|
189
|
+
|
|
190
|
+
- **Type**: `string[]`
|
|
191
|
+
- **Default**: [`["css"]`](./src/embedded/css/options.ts)
|
|
192
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded CSS language.
|
|
193
|
+
|
|
194
|
+
Please use `embeddedCssComments` or `embeddedCssTags`.
|
|
195
|
+
|
|
196
|
+
</details>
|
|
159
197
|
|
|
160
198
|
##### `embeddedCssParser`
|
|
161
199
|
|
|
@@ -165,17 +203,36 @@ This "language" doesn't require other plugins and can override the native embedd
|
|
|
165
203
|
|
|
166
204
|
Formatting embedded CSS language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
167
205
|
|
|
168
|
-
This can override the native formatting bahavior for embedded CSS language. If you want to keep the native behavior, set `
|
|
206
|
+
This can override the native formatting bahavior for embedded CSS language. If you want to keep the native behavior, set `embeddedCssComments` or `embeddedCssTags` to `[]` or other values.
|
|
169
207
|
|
|
170
|
-
If you want to specify different parsers for different
|
|
208
|
+
If you want to specify different parsers for different comments or tags, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
171
209
|
|
|
172
210
|
#### ES (ECMAScript/JavaScript)
|
|
173
211
|
|
|
174
|
-
##### `
|
|
212
|
+
##### `embeddedEsComments`
|
|
213
|
+
|
|
214
|
+
- **Type**: `string[]`
|
|
215
|
+
- **Default**: [`["js", "jsx", "es", "es6", "mjs", "cjs", "pac", "javascript"]`](./src/embedded/es/options.ts)
|
|
216
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded ECMAScript/JavaScript language.
|
|
217
|
+
|
|
218
|
+
##### `embeddedEsTags`
|
|
175
219
|
|
|
176
220
|
- **Type**: `string[]`
|
|
177
221
|
- **Default**: [`["js", "jsx", "es", "es6", "mjs", "cjs", "pac", "javascript"]`](./src/embedded/es/options.ts)
|
|
178
|
-
- **Description**:
|
|
222
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded ECMAScript/JavaScript language.
|
|
223
|
+
|
|
224
|
+
##### ~~`embeddedEsIdentifiers`~~
|
|
225
|
+
|
|
226
|
+
<details>
|
|
227
|
+
<summary>deprecated</summary>
|
|
228
|
+
|
|
229
|
+
- **Type**: `string[]`
|
|
230
|
+
- **Default**: [`["js", "jsx", "es", "es6", "mjs", "cjs", "pac", "javascript"]`](./src/embedded/es/options.ts)
|
|
231
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded ECMAScript/JavaScript language.
|
|
232
|
+
|
|
233
|
+
Please use `embeddedEsComments` or `embeddedEsTags`.
|
|
234
|
+
|
|
235
|
+
</details>
|
|
179
236
|
|
|
180
237
|
##### `embeddedEsParser`
|
|
181
238
|
|
|
@@ -185,37 +242,94 @@ If you want to specify different parsers for different identifiers, check [`embe
|
|
|
185
242
|
|
|
186
243
|
Formatting embedded ECMAScript/JavaScript language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
187
244
|
|
|
188
|
-
If you want to specify different parsers for different
|
|
245
|
+
If you want to specify different parsers for different comments or tags, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
189
246
|
|
|
190
247
|
#### GLSL
|
|
191
248
|
|
|
192
|
-
##### `
|
|
249
|
+
##### `embeddedGlslComments`
|
|
193
250
|
|
|
194
251
|
- **Type**: `string[]`
|
|
195
252
|
- **Default**: [`["glsl", "shader"]`](./src/embedded/glsl/options.ts)
|
|
196
|
-
- **Description**:
|
|
253
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded GLSL language. This option requires the `prettier-plugin-glsl` plugin.
|
|
254
|
+
|
|
255
|
+
##### `embeddedGlslTags`
|
|
256
|
+
|
|
257
|
+
- **Type**: `string[]`
|
|
258
|
+
- **Default**: [`["glsl", "shader"]`](./src/embedded/glsl/options.ts)
|
|
259
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded GLSL language. This option requires the `prettier-plugin-glsl` plugin.
|
|
260
|
+
|
|
261
|
+
##### ~~`embeddedGlslIdentifiers`~~
|
|
262
|
+
|
|
263
|
+
<details>
|
|
264
|
+
<summary>deprecated</summary>
|
|
265
|
+
|
|
266
|
+
- **Type**: `string[]`
|
|
267
|
+
- **Default**: [`["glsl", "shader"]`](./src/embedded/glsl/options.ts)
|
|
268
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded GLSL language. This option requires the `prettier-plugin-glsl` plugin.
|
|
269
|
+
|
|
270
|
+
Please use `embeddedGlslComments` or `embeddedGlslTags`.
|
|
271
|
+
|
|
272
|
+
</details>
|
|
197
273
|
|
|
198
274
|
Formatting embedded GLSL language requires the [`prettier-plugin-glsl`](https://github.com/NaridaL/glsl-language-toolkit/tree/main/packages/prettier-plugin-glsl) plugin to be loaded as well.
|
|
199
275
|
|
|
200
276
|
#### GraphQL
|
|
201
277
|
|
|
202
|
-
##### `
|
|
278
|
+
##### `embeddedGraphqlComments`
|
|
203
279
|
|
|
204
280
|
- **Type**: `string[]`
|
|
205
281
|
- **Default**: [`["graphql", "gql"]`](./src/embedded/graphql/options.ts)
|
|
206
|
-
- **Description**:
|
|
282
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded GraphQL language.
|
|
283
|
+
|
|
284
|
+
##### `embeddedGraphqlTags`
|
|
285
|
+
|
|
286
|
+
- **Type**: `string[]`
|
|
287
|
+
- **Default**: [`["graphql", "gql"]`](./src/embedded/graphql/options.ts)
|
|
288
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded GraphQL language.
|
|
289
|
+
|
|
290
|
+
##### ~~`embeddedGraphqlIdentifiers`~~
|
|
291
|
+
|
|
292
|
+
<details>
|
|
293
|
+
<summary>deprecated</summary>
|
|
294
|
+
|
|
295
|
+
- **Type**: `string[]`
|
|
296
|
+
- **Default**: [`["graphql", "gql"]`](./src/embedded/graphql/options.ts)
|
|
297
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded GraphQL language.
|
|
298
|
+
|
|
299
|
+
Please use `embeddedGraphqlComments` or `embeddedGraphqlTags`.
|
|
300
|
+
|
|
301
|
+
</details>
|
|
207
302
|
|
|
208
303
|
Formatting embedded GraphQL language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
209
304
|
|
|
210
|
-
This can override the native formatting behavior for embedded GraphQL language. If you want to keep the native behavior, set `
|
|
305
|
+
This can override the native formatting behavior for embedded GraphQL language. If you want to keep the native behavior, set `embeddedGraphqlComments` or `embeddedGraphqlTags` to `[]` or other values.
|
|
211
306
|
|
|
212
307
|
#### HTML
|
|
213
308
|
|
|
214
|
-
##### `
|
|
309
|
+
##### `embeddedHtmlComments`
|
|
310
|
+
|
|
311
|
+
- **Type**: `string[]`
|
|
312
|
+
- **Default**: [`["html", "xhtml"]`](./src/embedded/html/options.ts)
|
|
313
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded HTML language.
|
|
314
|
+
|
|
315
|
+
##### `embeddedHtmlTags`
|
|
215
316
|
|
|
216
317
|
- **Type**: `string[]`
|
|
217
318
|
- **Default**: [`["html", "xhtml"]`](./src/embedded/html/options.ts)
|
|
218
|
-
- **Description**:
|
|
319
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded HTML language.
|
|
320
|
+
|
|
321
|
+
##### ~~`embeddedHtmlIdentifiers`~~
|
|
322
|
+
|
|
323
|
+
<details>
|
|
324
|
+
<summary>deprecated</summary>
|
|
325
|
+
|
|
326
|
+
- **Type**: `string[]`
|
|
327
|
+
- **Default**: [`["html", "xhtml"]`](./src/embedded/html/options.ts)
|
|
328
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded HTML language.
|
|
329
|
+
|
|
330
|
+
Please use `embeddedHtmlComments` or `embeddedHtmlTags`.
|
|
331
|
+
|
|
332
|
+
</details>
|
|
219
333
|
|
|
220
334
|
##### `embeddedHtmlParser`
|
|
221
335
|
|
|
@@ -225,37 +339,94 @@ This can override the native formatting behavior for embedded GraphQL language.
|
|
|
225
339
|
|
|
226
340
|
Formatting embedded HTML language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
227
341
|
|
|
228
|
-
This can override the native formatting behavior for embedded HTML language. If you want to keep the native behavior, set `
|
|
342
|
+
This can override the native formatting behavior for embedded HTML language. If you want to keep the native behavior, set `embeddedHtmlComments` or `embeddedHtmlTags` to `[]` or other values.
|
|
229
343
|
|
|
230
|
-
If you want to specify different parsers for different
|
|
344
|
+
If you want to specify different parsers for different comments or tags, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
231
345
|
|
|
232
346
|
#### INI
|
|
233
347
|
|
|
234
|
-
##### `
|
|
348
|
+
##### `embeddedIniComments`
|
|
349
|
+
|
|
350
|
+
- **Type**: `string[]`
|
|
351
|
+
- **Default**: [`["ini", "cfg", "pro"]`](./src/embedded/ini/options.ts)
|
|
352
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded INI language. This option requires the `prettier-plugin-ini` plugin.
|
|
353
|
+
|
|
354
|
+
##### `embeddedIniTags`
|
|
355
|
+
|
|
356
|
+
- **Type**: `string[]`
|
|
357
|
+
- **Default**: [`["ini", "cfg", "pro"]`](./src/embedded/ini/options.ts)
|
|
358
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded INI language. This option requires the `prettier-plugin-ini` plugin.
|
|
359
|
+
|
|
360
|
+
##### ~~`embeddedIniIdentifiers`~~
|
|
361
|
+
|
|
362
|
+
<details>
|
|
363
|
+
<summary>deprecated</summary>
|
|
235
364
|
|
|
236
365
|
- **Type**: `string[]`
|
|
237
366
|
- **Default**: [`["ini", "cfg", "pro"]`](./src/embedded/ini/options.ts)
|
|
238
|
-
- **Description**:
|
|
367
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded INI language. This option requires the `prettier-plugin-ini` plugin.
|
|
368
|
+
|
|
369
|
+
Please use `embeddedIniComments` or `embeddedIniTags`.
|
|
370
|
+
|
|
371
|
+
</details>
|
|
239
372
|
|
|
240
373
|
Formatting embedded INI language requires the [`prettier-plugin-ini`](https://github.com/kddnewton/prettier-plugin-ini) plugin to be loaded as well. And [options](https://github.com/kddnewton/prettier-plugin-ini#configuration) supported by `prettier-plugin-ini` can therefore be used to further control the formatting behavior.
|
|
241
374
|
|
|
242
375
|
#### Java
|
|
243
376
|
|
|
244
|
-
##### `
|
|
377
|
+
##### `embeddedJavaComments`
|
|
378
|
+
|
|
379
|
+
- **Type**: `string[]`
|
|
380
|
+
- **Default**: [`["java"]`](./src/embedded/java/options.ts)
|
|
381
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded Java language. This option requires the `prettier-plugin-java` plugin.
|
|
382
|
+
|
|
383
|
+
##### `embeddedJavaTags`
|
|
384
|
+
|
|
385
|
+
- **Type**: `string[]`
|
|
386
|
+
- **Default**: [`["java"]`](./src/embedded/java/options.ts)
|
|
387
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded Java language. This option requires the `prettier-plugin-java` plugin.
|
|
388
|
+
|
|
389
|
+
##### ~~`embeddedJavaIdentifiers`~~
|
|
390
|
+
|
|
391
|
+
<details>
|
|
392
|
+
<summary>deprecated</summary>
|
|
245
393
|
|
|
246
394
|
- **Type**: `string[]`
|
|
247
395
|
- **Default**: [`["java"]`](./src/embedded/java/options.ts)
|
|
248
|
-
- **Description**:
|
|
396
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded Java language. This option requires the `prettier-plugin-java` plugin.
|
|
397
|
+
|
|
398
|
+
Please use `embeddedJavaComments` or `embeddedJavaTags`.
|
|
399
|
+
|
|
400
|
+
</details>
|
|
249
401
|
|
|
250
402
|
Formatting embedded Java language requires the [`prettier-plugin-java`](https://github.com/jhipster/prettier-java/tree/main/packages/prettier-plugin-java) plugin to be loaded as well. And [options](https://github.com/jhipster/prettier-java/tree/main/packages/prettier-plugin-java#options) supported by `prettier-plugin-java` can therefore be used to further control the formatting behavior.
|
|
251
403
|
|
|
252
404
|
#### JSON
|
|
253
405
|
|
|
254
|
-
##### `
|
|
406
|
+
##### `embeddedJsonComments`
|
|
255
407
|
|
|
256
408
|
- **Type**: `string[]`
|
|
257
409
|
- **Default**: [`["json", "jsonl"]`](./src/embedded/json/options.ts)
|
|
258
|
-
- **Description**:
|
|
410
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded JSON language.
|
|
411
|
+
|
|
412
|
+
##### `embeddedJsonTags`
|
|
413
|
+
|
|
414
|
+
- **Type**: `string[]`
|
|
415
|
+
- **Default**: [`["json", "jsonl"]`](./src/embedded/json/options.ts)
|
|
416
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded JSON language.
|
|
417
|
+
|
|
418
|
+
##### ~~`embeddedJsonIdentifiers`~~
|
|
419
|
+
|
|
420
|
+
<details>
|
|
421
|
+
<summary>deprecated</summary>
|
|
422
|
+
|
|
423
|
+
- **Type**: `string[]`
|
|
424
|
+
- **Default**: [`["json", "jsonl"]`](./src/embedded/json/options.ts)
|
|
425
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded JSON language.
|
|
426
|
+
|
|
427
|
+
Please use `embeddedJsonComments` or `embeddedJsonTags`.
|
|
428
|
+
|
|
429
|
+
</details>
|
|
259
430
|
|
|
260
431
|
##### `embeddedJsonParser`
|
|
261
432
|
|
|
@@ -265,35 +436,92 @@ Formatting embedded Java language requires the [`prettier-plugin-java`](https://
|
|
|
265
436
|
|
|
266
437
|
Formatting embedded JSON language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
267
438
|
|
|
268
|
-
If you want to specify different parsers for different
|
|
439
|
+
If you want to specify different parsers for different comments or tags, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
269
440
|
|
|
270
441
|
#### JSONata
|
|
271
442
|
|
|
272
|
-
##### `
|
|
443
|
+
##### `embeddedJsonataComments`
|
|
444
|
+
|
|
445
|
+
- **Type**: `string[]`
|
|
446
|
+
- **Default**: [`["jsonata"]`](./src/embedded/jsonata/options.ts)
|
|
447
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded JSONata language. This option requires the `@stedi/prettier-plugin-jsonata` plugin.
|
|
448
|
+
|
|
449
|
+
##### `embeddedJsonataTags`
|
|
273
450
|
|
|
274
451
|
- **Type**: `string[]`
|
|
275
452
|
- **Default**: [`["jsonata"]`](./src/embedded/jsonata/options.ts)
|
|
276
|
-
- **Description**:
|
|
453
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded JSONata language. This option requires the `@stedi/prettier-plugin-jsonata` plugin.
|
|
454
|
+
|
|
455
|
+
##### ~~`embeddedJsonataIdentifiers`~~
|
|
456
|
+
|
|
457
|
+
<details>
|
|
458
|
+
<summary>deprecated</summary>
|
|
459
|
+
|
|
460
|
+
- **Type**: `string[]`
|
|
461
|
+
- **Default**: [`["jsonata"]`](./src/embedded/jsonata/options.ts)
|
|
462
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded JSONata language. This option requires the `@stedi/prettier-plugin-jsonata` plugin.
|
|
463
|
+
|
|
464
|
+
Please use `embeddedJsonataComments` or `embeddedJsonataTags`.
|
|
465
|
+
|
|
466
|
+
</details>
|
|
277
467
|
|
|
278
468
|
Formatting embedded JSONata language requires the [`@stedi/prettier-plugin-jsonata`](https://github.com/Stedi/prettier-plugin-jsonata) plugin to be loaded as well.
|
|
279
469
|
|
|
280
470
|
#### LaTeX
|
|
281
471
|
|
|
282
|
-
##### `
|
|
472
|
+
##### `embeddedLatexComments`
|
|
473
|
+
|
|
474
|
+
- **Type**: `string[]`
|
|
475
|
+
- **Default**: [`["latex", "tex", "aux", "cls", "bbl", "bib", "toc", "sty"]`](./src/embedded/latex/options.ts)
|
|
476
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded LaTeX language. This option requires the `prettier-plugin-latex` plugin.
|
|
477
|
+
|
|
478
|
+
##### `embeddedLatexTags`
|
|
283
479
|
|
|
284
480
|
- **Type**: `string[]`
|
|
285
481
|
- **Default**: [`["latex", "tex", "aux", "cls", "bbl", "bib", "toc", "sty"]`](./src/embedded/latex/options.ts)
|
|
286
|
-
- **Description**:
|
|
482
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded LaTeX language. This option requires the `prettier-plugin-latex` plugin.
|
|
483
|
+
|
|
484
|
+
##### ~~`embeddedLatexIdentifiers`~~
|
|
485
|
+
|
|
486
|
+
<details>
|
|
487
|
+
<summary>deprecated</summary>
|
|
488
|
+
|
|
489
|
+
- **Type**: `string[]`
|
|
490
|
+
- **Default**: [`["latex", "tex", "aux", "cls", "bbl", "bib", "toc", "sty"]`](./src/embedded/latex/options.ts)
|
|
491
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded LaTeX language. This option requires the `prettier-plugin-latex` plugin.
|
|
492
|
+
|
|
493
|
+
Please use `embeddedLatexComments` or `embeddedLatexTags`.
|
|
494
|
+
|
|
495
|
+
</details>
|
|
287
496
|
|
|
288
497
|
Formatting embedded LaTeX language requires the [`prettier-plugin-latex`](https://github.com/siefkenj/prettier-plugin-latex) plugin to be loaded as well.
|
|
289
498
|
|
|
290
499
|
#### Markdown
|
|
291
500
|
|
|
292
|
-
##### `
|
|
501
|
+
##### `embeddedMarkdownComments`
|
|
502
|
+
|
|
503
|
+
- **Type**: `string[]`
|
|
504
|
+
- **Default**: [`["md", "markdown"]`](./src/embedded/markdown/options.ts)
|
|
505
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded Markdown language.
|
|
506
|
+
|
|
507
|
+
##### `embeddedMarkdownTags`
|
|
508
|
+
|
|
509
|
+
- **Type**: `string[]`
|
|
510
|
+
- **Default**: [`["md", "markdown"]`](./src/embedded/markdown/options.ts)
|
|
511
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded Markdown language.
|
|
512
|
+
|
|
513
|
+
##### ~~`embeddedMarkdownIdentifiers`~~
|
|
514
|
+
|
|
515
|
+
<details>
|
|
516
|
+
<summary>deprecated</summary>
|
|
293
517
|
|
|
294
518
|
- **Type**: `string[]`
|
|
295
519
|
- **Default**: [`["md", "markdown"]`](./src/embedded/markdown/options.ts)
|
|
296
|
-
- **Description**:
|
|
520
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded Markdown language.
|
|
521
|
+
|
|
522
|
+
Please use `embeddedMarkdownComments` or `embeddedMarkdownTags`.
|
|
523
|
+
|
|
524
|
+
</details>
|
|
297
525
|
|
|
298
526
|
##### `embeddedMarkdownParser`
|
|
299
527
|
|
|
@@ -303,81 +531,214 @@ Formatting embedded LaTeX language requires the [`prettier-plugin-latex`](https:
|
|
|
303
531
|
|
|
304
532
|
Formatting embedded Markdown language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
305
533
|
|
|
306
|
-
This can override the native formatting for embedded Markdown language. If you want to keep the native behavior, set `
|
|
534
|
+
This can override the native formatting for embedded Markdown language. If you want to keep the native behavior, set `embeddedMarkdownComments` or `embeddedMarkdownTags` to `[]` or other values.
|
|
307
535
|
|
|
308
|
-
If you want to specify different parsers for different
|
|
536
|
+
If you want to specify different parsers for different comments or tags, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
309
537
|
|
|
310
538
|
The `remark` parser is [an alias of the `markdown` parser](https://github.com/prettier/prettier/blob/ed23dacc9e655c3876971b30859497b17ff2cf9f/src/language-markdown/parser-markdown.js#L57).
|
|
311
539
|
|
|
312
540
|
#### NGINX
|
|
313
541
|
|
|
314
|
-
##### `
|
|
542
|
+
##### `embeddedNginxComments`
|
|
315
543
|
|
|
316
544
|
- **Type**: `string[]`
|
|
317
545
|
- **Default**: [`["nginx"]`](./src/embedded/nginx/options.ts)
|
|
318
|
-
- **Description**:
|
|
546
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded NGINX language. This option requires the `prettier-plugin-nginx` plugin.
|
|
547
|
+
|
|
548
|
+
##### `embeddedNginxTags`
|
|
549
|
+
|
|
550
|
+
- **Type**: `string[]`
|
|
551
|
+
- **Default**: [`["nginx"]`](./src/embedded/nginx/options.ts)
|
|
552
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded NGINX language. This option requires the `prettier-plugin-nginx` plugin.
|
|
553
|
+
|
|
554
|
+
##### ~~`embeddedNginxIdentifiers`~~
|
|
555
|
+
|
|
556
|
+
<details>
|
|
557
|
+
<summary>deprecated</summary>
|
|
558
|
+
|
|
559
|
+
- **Type**: `string[]`
|
|
560
|
+
- **Default**: [`["nginx"]`](./src/embedded/nginx/options.ts)
|
|
561
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded NGINX language. This option requires the `prettier-plugin-nginx` plugin.
|
|
562
|
+
|
|
563
|
+
Please use `embeddedNginxComments` or `embeddedNginxTags`.
|
|
564
|
+
|
|
565
|
+
</details>
|
|
319
566
|
|
|
320
567
|
Formatting embedded NGINX language requires the [`prettier-plugin-nginx`](https://github.com/jxddk/prettier-plugin-nginx) plugin to be loaded as well. And [options](https://github.com/jxddk/prettier-plugin-nginx?tab=readme-ov-file#configuration) supported by `prettier-plugin-nginx` can therefore be used to further control the formatting behavior.
|
|
321
568
|
|
|
322
569
|
#### Pegjs
|
|
323
570
|
|
|
324
|
-
##### `
|
|
571
|
+
##### `embeddedPegjsComments`
|
|
572
|
+
|
|
573
|
+
- **Type**: `string[]`
|
|
574
|
+
- **Default**: [`["pegjs", "peggy", "peg"]`](./src/embedded/pegjs/options.ts)
|
|
575
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded Pegjs language. This option requires the `prettier-plugin-pegjs` plugin.
|
|
576
|
+
|
|
577
|
+
##### `embeddedPegjsTags`
|
|
578
|
+
|
|
579
|
+
- **Type**: `string[]`
|
|
580
|
+
- **Default**: [`["pegjs", "peggy", "peg"]`](./src/embedded/pegjs/options.ts)
|
|
581
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded Pegjs language. This option requires the `prettier-plugin-pegjs` plugin.
|
|
582
|
+
|
|
583
|
+
##### ~~`embeddedPegjsIdentifiers`~~
|
|
584
|
+
|
|
585
|
+
<details>
|
|
586
|
+
<summary>deprecated</summary>
|
|
325
587
|
|
|
326
588
|
- **Type**: `string[]`
|
|
327
589
|
- **Default**: [`["pegjs", "peggy", "peg"]`](./src/embedded/pegjs/options.ts)
|
|
328
|
-
- **Description**:
|
|
590
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded Pegjs language. This option requires the `prettier-plugin-pegjs` plugin.
|
|
591
|
+
|
|
592
|
+
Please use `embeddedPegjsComments` or `embeddedPegjsTags`.
|
|
593
|
+
|
|
594
|
+
</details>
|
|
329
595
|
|
|
330
596
|
Formatting embedded Pegjs language requires the [`prettier-plugin-pegjs`](https://github.com/siefkenj/prettier-plugin-pegjs) plugin to be loaded as well. And [options](https://github.com/siefkenj/prettier-plugin-pegjs?tab=readme-ov-file#options) supported by `prettier-plugin-pegjs` can therefore be used to further control the formatting behavior.
|
|
331
597
|
|
|
332
|
-
Note that `prettier-plugin-pegjs` supports different parsers for the action blocks and they are specified by the [`actionParser` option](https://github.com/siefkenj/prettier-plugin-pegjs?tab=readme-ov-file#options). If you want to specify different action parsers for different
|
|
598
|
+
Note that `prettier-plugin-pegjs` supports different parsers for the action blocks and they are specified by the [`actionParser` option](https://github.com/siefkenj/prettier-plugin-pegjs?tab=readme-ov-file#options). If you want to specify different action parsers for different comments or tags, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
333
599
|
|
|
334
600
|
#### PHP
|
|
335
601
|
|
|
336
|
-
##### `
|
|
602
|
+
##### `embeddedPhpComments`
|
|
603
|
+
|
|
604
|
+
- **Type**: `string[]`
|
|
605
|
+
- **Default**: [`["php", "php5"]`](./src/embedded/php/options.ts)
|
|
606
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded PHP language. This option requires the `@prettier/plugin-php` plugin.
|
|
607
|
+
|
|
608
|
+
##### `embeddedPhpTags`
|
|
337
609
|
|
|
338
610
|
- **Type**: `string[]`
|
|
339
611
|
- **Default**: [`["php", "php5"]`](./src/embedded/php/options.ts)
|
|
340
|
-
- **Description**:
|
|
612
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded PHP language. This option requires the `@prettier/plugin-php` plugin.
|
|
613
|
+
|
|
614
|
+
##### ~~`embeddedPhpIdentifiers`~~
|
|
615
|
+
|
|
616
|
+
<details>
|
|
617
|
+
<summary>deprecated</summary>
|
|
618
|
+
|
|
619
|
+
- **Type**: `string[]`
|
|
620
|
+
- **Default**: [`["php", "php5"]`](./src/embedded/php/options.ts)
|
|
621
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded PHP language. This option requires the `@prettier/plugin-php` plugin.
|
|
622
|
+
|
|
623
|
+
Please use `embeddedPhpComments` or `embeddedPhpTags`.
|
|
624
|
+
|
|
625
|
+
</details>
|
|
341
626
|
|
|
342
627
|
Formatting embedded PHP language requires the [`@prettier/plugin-php`](https://github.com/prettier/plugin-php) plugin to be loaded as well. And [options](https://github.com/prettier/plugin-php#configuration) supported by `@prettier/plugin-php` can therefore be used to further control the formatting behavior.
|
|
343
628
|
|
|
344
629
|
#### Prisma
|
|
345
630
|
|
|
346
|
-
##### `
|
|
631
|
+
##### `embeddedPrismaComments`
|
|
632
|
+
|
|
633
|
+
- **Type**: `string[]`
|
|
634
|
+
- **Default**: [`["prisma"]`](./src/embedded/prisma/options.ts)
|
|
635
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded Prisma language. This option requires the `prettier-plugin-prisma` plugin.
|
|
636
|
+
|
|
637
|
+
##### `embeddedPrismaTags`
|
|
347
638
|
|
|
348
639
|
- **Type**: `string[]`
|
|
349
640
|
- **Default**: [`["prisma"]`](./src/embedded/prisma/options.ts)
|
|
350
|
-
- **Description**:
|
|
641
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded Prisma language. This option requires the `prettier-plugin-prisma` plugin.
|
|
642
|
+
|
|
643
|
+
##### ~~`embeddedPrismaIdentifiers`~~
|
|
644
|
+
|
|
645
|
+
<details>
|
|
646
|
+
<summary>deprecated</summary>
|
|
647
|
+
|
|
648
|
+
- **Type**: `string[]`
|
|
649
|
+
- **Default**: [`["prisma"]`](./src/embedded/prisma/options.ts)
|
|
650
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded Prisma language. This option requires the `prettier-plugin-prisma` plugin.
|
|
651
|
+
|
|
652
|
+
Please use `embeddedPrismaComments` or `embeddedPrismaTags`.
|
|
653
|
+
|
|
654
|
+
</details>
|
|
351
655
|
|
|
352
656
|
Formatting embedded Prisma language requires the [`prettier-plugin-prisma`](https://github.com/avocadowastaken/prettier-plugin-prisma) plugin to be loaded as well.
|
|
353
657
|
|
|
354
658
|
#### Properties
|
|
355
659
|
|
|
356
|
-
##### `
|
|
660
|
+
##### `embeddedPropertiesComments`
|
|
357
661
|
|
|
358
662
|
- **Type**: `string[]`
|
|
359
663
|
- **Default**: [`["properties"]`](./src/embedded/properties/options.ts)
|
|
360
|
-
- **Description**:
|
|
664
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded Properties language. This option requires the `prettier-plugin-properties` plugin.
|
|
665
|
+
|
|
666
|
+
##### `embeddedPropertiesTags`
|
|
667
|
+
|
|
668
|
+
- **Type**: `string[]`
|
|
669
|
+
- **Default**: [`["properties"]`](./src/embedded/properties/options.ts)
|
|
670
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded Properties language. This option requires the `prettier-plugin-properties` plugin.
|
|
671
|
+
|
|
672
|
+
##### ~~`embeddedPropertiesIdentifiers`~~
|
|
673
|
+
|
|
674
|
+
<details>
|
|
675
|
+
<summary>deprecated</summary>
|
|
676
|
+
|
|
677
|
+
- **Type**: `string[]`
|
|
678
|
+
- **Default**: [`["properties"]`](./src/embedded/properties/options.ts)
|
|
679
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded Properties language. This option requires the `prettier-plugin-properties` plugin.
|
|
680
|
+
|
|
681
|
+
Please use `embeddedPropertiesComments` or `embeddedPropertiesTags`.
|
|
682
|
+
|
|
683
|
+
</details>
|
|
361
684
|
|
|
362
685
|
Formatting embedded Properties language requires the [`prettier-plugin-properties`](https://github.com/eemeli/prettier-plugin-properties) plugin to be loaded as well. And [options](https://github.com/eemeli/prettier-plugin-properties#configuration) supported by `prettier-plugin-properties` can therefore be used to further control the formatting behavior.
|
|
363
686
|
|
|
364
687
|
#### Pug
|
|
365
688
|
|
|
366
|
-
##### `
|
|
689
|
+
##### `embeddedPugComments`
|
|
690
|
+
|
|
691
|
+
- **Type**: `string[]`
|
|
692
|
+
- **Default**: [`["pug", "jade"]`](./src/embedded/pug/options.ts)
|
|
693
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded Pug language. This option requires the `@prettier/plugin-pug` plugin.
|
|
694
|
+
|
|
695
|
+
##### `embeddedPugTags`
|
|
696
|
+
|
|
697
|
+
- **Type**: `string[]`
|
|
698
|
+
- **Default**: [`["pug", "jade"]`](./src/embedded/pug/options.ts)
|
|
699
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded Pug language. This option requires the `@prettier/plugin-pug` plugin.
|
|
700
|
+
|
|
701
|
+
##### ~~`embeddedPugIdentifiers`~~
|
|
702
|
+
|
|
703
|
+
<details>
|
|
704
|
+
<summary>deprecated</summary>
|
|
367
705
|
|
|
368
706
|
- **Type**: `string[]`
|
|
369
707
|
- **Default**: [`["pug", "jade"]`](./src/embedded/pug/options.ts)
|
|
370
|
-
- **Description**:
|
|
708
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded Pug language. This option requires the `@prettier/plugin-pug` plugin.
|
|
709
|
+
|
|
710
|
+
Please use `embeddedPugComments` or `embeddedPugTags`.
|
|
711
|
+
|
|
712
|
+
</details>
|
|
371
713
|
|
|
372
714
|
Formatting embedded Pug language requires the [`@prettier/plugin-pug`](https://github.com/prettier/plugin-pug) plugin to be loaded as well. And [options](https://github.com/prettier/plugin-pug?tab=readme-ov-file#configuration) supported by `@prettier/plugin-pug` can therefore be used to further control the formatting behavior.
|
|
373
715
|
|
|
374
716
|
#### Ruby
|
|
375
717
|
|
|
376
|
-
##### `
|
|
718
|
+
##### `embeddedRubyComments`
|
|
719
|
+
|
|
720
|
+
- **Type**: `string[]`
|
|
721
|
+
- **Default**: [`["ruby"]`](./src/embedded/ruby/options.ts)
|
|
722
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded Ruby language. This option requires the `@prettier/plugin-ruby` plugin.
|
|
723
|
+
|
|
724
|
+
##### `embeddedRubyTags`
|
|
377
725
|
|
|
378
726
|
- **Type**: `string[]`
|
|
379
727
|
- **Default**: [`["ruby"]`](./src/embedded/ruby/options.ts)
|
|
380
|
-
- **Description**:
|
|
728
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded Ruby language. This option requires the `@prettier/plugin-ruby` plugin.
|
|
729
|
+
|
|
730
|
+
##### ~~`embeddedRubyIdentifiers`~~
|
|
731
|
+
|
|
732
|
+
<details>
|
|
733
|
+
<summary>deprecated</summary>
|
|
734
|
+
|
|
735
|
+
- **Type**: `string[]`
|
|
736
|
+
- **Default**: [`["ruby"]`](./src/embedded/ruby/options.ts)
|
|
737
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded Ruby language. This option requires the `@prettier/plugin-ruby` plugin.
|
|
738
|
+
|
|
739
|
+
Please use `embeddedRubyComments` or `embeddedRubyTags`.
|
|
740
|
+
|
|
741
|
+
</details>
|
|
381
742
|
|
|
382
743
|
##### `embeddedRubyParser`
|
|
383
744
|
|
|
@@ -387,27 +748,65 @@ Formatting embedded Pug language requires the [`@prettier/plugin-pug`](https://g
|
|
|
387
748
|
|
|
388
749
|
Formatting embedded Ruby language requires the [`@prettier/plugin-ruby`](https://github.com/prettier/plugin-ruby) to be loaded and [its dependencies to be installed](https://github.com/prettier/plugin-ruby#getting-started) as well. And [options](https://github.com/prettier/plugin-ruby#configuration) supported by `@prettier/plugin-ruby` can therefore be used to further control the formatting behavior.
|
|
389
750
|
|
|
390
|
-
If you want to specify different parsers for different
|
|
751
|
+
If you want to specify different parsers for different comments or tags, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
391
752
|
|
|
392
753
|
#### Sh (Shell)
|
|
393
754
|
|
|
394
|
-
##### `
|
|
755
|
+
##### `embeddedShComments`
|
|
756
|
+
|
|
757
|
+
- **Type**: `string[]`
|
|
758
|
+
- **Default**: [`["sh"]`](./src/embedded/sh/options.ts)
|
|
759
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded Shell language. This option requires the `prettier-plugin-sh` plugin.
|
|
760
|
+
|
|
761
|
+
##### `embeddedShTags`
|
|
762
|
+
|
|
763
|
+
- **Type**: `string[]`
|
|
764
|
+
- **Default**: [`["sh"]`](./src/embedded/sh/options.ts)
|
|
765
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded Shell language. This option requires the `prettier-plugin-sh` plugin.
|
|
766
|
+
|
|
767
|
+
##### ~~`embeddedShIdentifiers`~~
|
|
768
|
+
|
|
769
|
+
<details>
|
|
770
|
+
<summary>deprecated</summary>
|
|
395
771
|
|
|
396
772
|
- **Type**: `string[]`
|
|
397
773
|
- **Default**: [`["sh"]`](./src/embedded/sh/options.ts)
|
|
398
|
-
- **Description**:
|
|
774
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded Shell language. This option requires the `prettier-plugin-sh` plugin.
|
|
775
|
+
|
|
776
|
+
Please use `embeddedShComments` or `embeddedShTags`.
|
|
777
|
+
|
|
778
|
+
</details>
|
|
399
779
|
|
|
400
780
|
Formatting embedded Shell language requires the [`prettier-plugin-sh`](https://github.com/un-ts/prettier/tree/master/packages/sh#readme) plugin to be loaded as well. And [options](https://github.com/un-ts/prettier/tree/master/packages/sh#parser-options) supported by `prettier-plugin-sh` can therefore be used to further control the formatting behavior.
|
|
401
781
|
|
|
402
|
-
Note that `prettier-plugin-sh` supports different variants of shell syntaxes and they are specified by the [`variant` option](https://github.com/un-ts/prettier/tree/master/packages/sh#parser-options). If you want to specify different variants for different
|
|
782
|
+
Note that `prettier-plugin-sh` supports different variants of shell syntaxes and they are specified by the [`variant` option](https://github.com/un-ts/prettier/tree/master/packages/sh#parser-options). If you want to specify different variants for different comments or tags, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
403
783
|
|
|
404
784
|
#### SQL
|
|
405
785
|
|
|
406
|
-
##### `
|
|
786
|
+
##### `embeddedSqlComments`
|
|
787
|
+
|
|
788
|
+
- **Type**: `string[]`
|
|
789
|
+
- **Default**: [`["sql"]`](./src/embedded/sql/options.ts)
|
|
790
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded SQL language. This option requires the `prettier-plugin-sql` plugin or the `prettier-plugin-sql-cst` plugin.
|
|
791
|
+
|
|
792
|
+
##### `embeddedSqlTags`
|
|
793
|
+
|
|
794
|
+
- **Type**: `string[]`
|
|
795
|
+
- **Default**: [`["sql"]`](./src/embedded/sql/options.ts)
|
|
796
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded SQL language. This option requires the `prettier-plugin-sql` plugin or the `prettier-plugin-sql-cst` plugin.
|
|
797
|
+
|
|
798
|
+
##### ~~`embeddedSqlIdentifiers`~~
|
|
799
|
+
|
|
800
|
+
<details>
|
|
801
|
+
<summary>deprecated</summary>
|
|
407
802
|
|
|
408
803
|
- **Type**: `string[]`
|
|
409
804
|
- **Default**: [`["sql"]`](./src/embedded/sql/options.ts)
|
|
410
|
-
- **Description**:
|
|
805
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded SQL language. This option requires the `prettier-plugin-sql` plugin or the `prettier-plugin-sql-cst` plugin.
|
|
806
|
+
|
|
807
|
+
Please use `embeddedSqlComments` or `embeddedSqlTags`.
|
|
808
|
+
|
|
809
|
+
</details>
|
|
411
810
|
|
|
412
811
|
##### `embeddedSqlPlugin`
|
|
413
812
|
|
|
@@ -423,25 +822,63 @@ Note that `prettier-plugin-sh` supports different variants of shell syntaxes and
|
|
|
423
822
|
|
|
424
823
|
Formatting embedded SQL language requires the [`prettier-plugin-sql`](https://github.com/un-ts/prettier/tree/master/packages/sql#readme) plugin or the [`prettier-plugin-sql-cst`](https://github.com/nene/prettier-plugin-sql-cst) plugin to be loaded as well. And [options](https://github.com/un-ts/prettier/tree/master/packages/sql#parser-options) supported by `prettier-plugin-sql`, or [options](https://github.com/nene/prettier-plugin-sql-cst?tab=readme-ov-file#configuration) supported by `prettier-plugin-sql-cst` can therefore be used to further control the formatting behavior.
|
|
425
824
|
|
|
426
|
-
Note that `prettier-plugin-sql` supports many different SQL dialects which are specified by the [`language`, `database` or `dialect` option](https://github.com/un-ts/prettier/tree/master/packages/sql#parser-options). And `prettier-plugin-sql-cst` also supports various parsers as shown above. If you want to specify different dialects or parsers for different
|
|
825
|
+
Note that `prettier-plugin-sql` supports many different SQL dialects which are specified by the [`language`, `database` or `dialect` option](https://github.com/un-ts/prettier/tree/master/packages/sql#parser-options). And `prettier-plugin-sql-cst` also supports various parsers as shown above. If you want to specify different dialects or parsers for different comments or tags, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
427
826
|
|
|
428
827
|
#### TOML
|
|
429
828
|
|
|
430
|
-
##### `
|
|
829
|
+
##### `embeddedTomlComments`
|
|
830
|
+
|
|
831
|
+
- **Type**: `string[]`
|
|
832
|
+
- **Default**: [`["toml"]`](./src/embedded/toml/options.ts)
|
|
833
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded TOML language. This option requires the `prettier-plugin-toml` plugin.
|
|
834
|
+
|
|
835
|
+
##### `embeddedTomlTags`
|
|
836
|
+
|
|
837
|
+
- **Type**: `string[]`
|
|
838
|
+
- **Default**: [`["toml"]`](./src/embedded/toml/options.ts)
|
|
839
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded TOML language. This option requires the `prettier-plugin-toml` plugin.
|
|
840
|
+
|
|
841
|
+
##### ~~`embeddedTomlIdentifiers`~~
|
|
842
|
+
|
|
843
|
+
<details>
|
|
844
|
+
<summary>deprecated</summary>
|
|
431
845
|
|
|
432
846
|
- **Type**: `string[]`
|
|
433
847
|
- **Default**: [`["toml"]`](./src/embedded/toml/options.ts)
|
|
434
|
-
- **Description**:
|
|
848
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded TOML language. This option requires the `prettier-plugin-toml` plugin.
|
|
849
|
+
|
|
850
|
+
Please use `embeddedTomlComments` or `embeddedTomlTags`.
|
|
851
|
+
|
|
852
|
+
</details>
|
|
435
853
|
|
|
436
854
|
Formatting embedded TOML language requires the [`prettier-plugin-toml`](https://github.com/un-ts/prettier/tree/master/packages/toml#readme) plugin to be loaded as well. And [options](https://github.com/un-ts/prettier/blob/master/packages/toml/src/options.ts) supported by `prettier-plugin-toml` can therefore be used to further control the formatting behavior.
|
|
437
855
|
|
|
438
856
|
#### TS (TypeScript)
|
|
439
857
|
|
|
440
|
-
##### `
|
|
858
|
+
##### `embeddedTsComments`
|
|
441
859
|
|
|
442
860
|
- **Type**: `string[]`
|
|
443
861
|
- **Default**: [`["ts", "tsx", "cts", "mts", "typescript"]`](./src/embedded/ts/options.ts)
|
|
444
|
-
- **Description**:
|
|
862
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded TypeScript language.
|
|
863
|
+
|
|
864
|
+
##### `embeddedTsTags`
|
|
865
|
+
|
|
866
|
+
- **Type**: `string[]`
|
|
867
|
+
- **Default**: [`["ts", "tsx", "cts", "mts", "typescript"]`](./src/embedded/ts/options.ts)
|
|
868
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded TypeScript language.
|
|
869
|
+
|
|
870
|
+
##### ~~`embeddedTsIdentifiers`~~
|
|
871
|
+
|
|
872
|
+
<details>
|
|
873
|
+
<summary>deprecated</summary>
|
|
874
|
+
|
|
875
|
+
- **Type**: `string[]`
|
|
876
|
+
- **Default**: [`["ts", "tsx", "cts", "mts", "typescript"]`](./src/embedded/ts/options.ts)
|
|
877
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded TypeScript language.
|
|
878
|
+
|
|
879
|
+
Please use `embeddedTsComments` or `embeddedTsTags`.
|
|
880
|
+
|
|
881
|
+
</details>
|
|
445
882
|
|
|
446
883
|
##### `embeddedTsParser`
|
|
447
884
|
|
|
@@ -451,25 +888,63 @@ Formatting embedded TOML language requires the [`prettier-plugin-toml`](https://
|
|
|
451
888
|
|
|
452
889
|
Formatting embedded TypeScript language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
453
890
|
|
|
454
|
-
If you want to specify different parsers for different
|
|
891
|
+
If you want to specify different parsers for different comments or tags, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
455
892
|
|
|
456
893
|
#### XML
|
|
457
894
|
|
|
458
|
-
##### `
|
|
895
|
+
##### `embeddedXmlComments`
|
|
896
|
+
|
|
897
|
+
- **Type**: `string[]`
|
|
898
|
+
- **Default**: [`["xml", "opml", "rss", "svg"]`](./src/embedded/xml/options.ts)
|
|
899
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded XML language. This option requires the `@prettier/plugin-xml` plugin.
|
|
900
|
+
|
|
901
|
+
##### `embeddedXmlTags`
|
|
459
902
|
|
|
460
903
|
- **Type**: `string[]`
|
|
461
904
|
- **Default**: [`["xml", "opml", "rss", "svg"]`](./src/embedded/xml/options.ts)
|
|
462
|
-
- **Description**:
|
|
905
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded XML language. This option requires the `@prettier/plugin-xml` plugin.
|
|
906
|
+
|
|
907
|
+
##### ~~`embeddedXmlIdentifiers`~~
|
|
908
|
+
|
|
909
|
+
<details>
|
|
910
|
+
<summary>deprecated</summary>
|
|
911
|
+
|
|
912
|
+
- **Type**: `string[]`
|
|
913
|
+
- **Default**: [`["xml", "opml", "rss", "svg"]`](./src/embedded/xml/options.ts)
|
|
914
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded XML language. This option requires the `@prettier/plugin-xml` plugin.
|
|
915
|
+
|
|
916
|
+
Please use `embeddedXmlComments` or `embeddedXmlTags`.
|
|
917
|
+
|
|
918
|
+
</details>
|
|
463
919
|
|
|
464
920
|
Formatting embedded XML language requires the [`@prettier/plugin-xml`](https://github.com/prettier/plugin-xml) plugin to be loaded as well. And [options](https://github.com/prettier/plugin-xml#configuration) supported by `@prettier/plugin-xml` can therefore be used to further control the formatting behavior.
|
|
465
921
|
|
|
466
922
|
#### YAML
|
|
467
923
|
|
|
468
|
-
##### `
|
|
924
|
+
##### `embeddedYamlComments`
|
|
925
|
+
|
|
926
|
+
- **Type**: `string[]`
|
|
927
|
+
- **Default**: [`["yaml", "yml"]`](./src/embedded/yaml/options.ts)
|
|
928
|
+
- **Description**: Block comments that make their subsequent template literals be identified as embedded YAML language.
|
|
929
|
+
|
|
930
|
+
##### `embeddedYamlTags`
|
|
931
|
+
|
|
932
|
+
- **Type**: `string[]`
|
|
933
|
+
- **Default**: [`["yaml", "yml"]`](./src/embedded/yaml/options.ts)
|
|
934
|
+
- **Description**: Tags that make their subsequent template literals be identified as embedded YAML language.
|
|
935
|
+
|
|
936
|
+
##### ~~`embeddedYamlIdentifiers`~~
|
|
937
|
+
|
|
938
|
+
<details>
|
|
939
|
+
<summary>deprecated</summary>
|
|
469
940
|
|
|
470
941
|
- **Type**: `string[]`
|
|
471
942
|
- **Default**: [`["yaml", "yml"]`](./src/embedded/yaml/options.ts)
|
|
472
|
-
- **Description**:
|
|
943
|
+
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded YAML language.
|
|
944
|
+
|
|
945
|
+
Please use `embeddedYamlComments` or `embeddedYamlTags`.
|
|
946
|
+
|
|
947
|
+
</details>
|
|
473
948
|
|
|
474
949
|
Formatting embedded YAML language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
475
950
|
|
|
@@ -479,60 +954,74 @@ Formatting embedded YAML language doesn't require other plugins and uses the par
|
|
|
479
954
|
|
|
480
955
|
#### Language-Agnostic
|
|
481
956
|
|
|
482
|
-
#####
|
|
957
|
+
##### ~~`noEmbeddedIdentificationByComment`~~
|
|
958
|
+
|
|
959
|
+
<details>
|
|
960
|
+
<summary>deprecated</summary>
|
|
483
961
|
|
|
484
962
|
- **Type**: `string[]`
|
|
485
963
|
- **Default**: `[]`
|
|
486
|
-
- **Description**: Turns off `` /*
|
|
964
|
+
- **Description**: Turns off `` /* comment */ `...` `` comment-based embedded language identification for the specified identifiers.
|
|
965
|
+
|
|
966
|
+
Please use `embedded<Language>Comments` or `embedded<Language>Tags` to configure each embedded language, and you won't need this option anymore.
|
|
967
|
+
|
|
968
|
+
</details>
|
|
487
969
|
|
|
488
|
-
#####
|
|
970
|
+
##### ~~`noEmbeddedIdentificationByTag`~~
|
|
971
|
+
|
|
972
|
+
<details>
|
|
973
|
+
<summary>deprecated</summary>
|
|
489
974
|
|
|
490
975
|
- **Type**: `string[]`
|
|
491
976
|
- **Default**: `[]`
|
|
492
|
-
- **Description**: Turns off ``
|
|
977
|
+
- **Description**: Turns off `` tag`...` `` tag-based embedded language identification for the specified identifiers.
|
|
978
|
+
|
|
979
|
+
Please use `embedded<Language>Comments` or `embedded<Language>Tags` to configure each embedded language, and you won't need this option anymore.
|
|
980
|
+
|
|
981
|
+
</details>
|
|
493
982
|
|
|
494
983
|
##### `preserveEmbeddedExteriorWhitespaces`
|
|
495
984
|
|
|
496
985
|
- **Type**: `string[]`
|
|
497
986
|
- **Default**: `[]`
|
|
498
|
-
- **Description**: Preserves leading and trailing whitespaces in the formatting results for the specified
|
|
987
|
+
- **Description**: Preserves leading and trailing whitespaces in the formatting results for the specified comments or tags.
|
|
499
988
|
|
|
500
989
|
##### `noEmbeddedMultiLineIndentation`
|
|
501
990
|
|
|
502
991
|
- **Type**: `string[]`
|
|
503
992
|
- **Default**: `[]`
|
|
504
|
-
- **Description**: Turns off auto indentation in the formatting results when they are formatted to span multi lines
|
|
993
|
+
- **Description**: Turns off auto indentation in the formatting results for the specified comments or tags when they are formatted to span multi lines.
|
|
505
994
|
|
|
506
995
|
##### `embeddedOverrides`
|
|
507
996
|
|
|
508
997
|
- **Type**: `string`
|
|
509
998
|
- **Default**: `undefined`
|
|
510
|
-
- **Description**: Option overrides for the specified
|
|
999
|
+
- **Description**: Option overrides for the specified comments or tags. It should either be a stringified JSON or an absolute filepath to the option overrides file. See [below](#embeddedoverrides-1) for a detailed explanation.
|
|
511
1000
|
|
|
512
1001
|
#### `embeddedOverrides`
|
|
513
1002
|
|
|
514
|
-
This option is provided for users to override certain options based on
|
|
1003
|
+
This option is provided for users to override certain options based on comments or tags. Due to the lack of support for using objects in prettier plugin options (https://github.com/prettier/prettier/issues/14671), it accepts a **stringified** json string, or a file path with an extension of `.json`, `.jsonc`, `.js`, `.cjs`, `.mjs`, `.ts`, `.cts` or `.mts` as its value. If no extension is provided, it will be treated as a `.json`/`.jsonc` file. For relative paths, it will automatically figure out the prettier config location and use that as the base path.
|
|
515
1004
|
|
|
516
1005
|
> [!NOTE]
|
|
517
1006
|
>
|
|
518
1007
|
> The support for using `.ts`, `.mts` or `.cts` files for `embeddedOverrides` requires a minimal `node` version of [18.19.0](https://nodejs.org/en/blog/release/v18.19.0#esm-and-customization-hook-changes), and [`tsx`](https://github.com/privatenumber/tsx) as a dependency in your project. And it currently doesn't work with the Prettier VSCode extension.
|
|
519
1008
|
|
|
520
|
-
The resolved value should be an array of objects. Each object in the array must have 2 fields: `
|
|
1009
|
+
The resolved value should be an array of objects. Each object in the array must have 2 fields: `comments` and `options`, or `tags` and `options`. The `options` are considerred overrides that will be applied to the global `options` of prettier for those `comments` and `tags` only. It's like the [`overrides`](https://prettier.io/docs/en/configuration.html#configuration-overrides) of `prettier`, but it is comment/tag-based instead of file-based.
|
|
521
1010
|
|
|
522
|
-
In a json file, the root is the array of objects. In a JavaScript file, the array of objects should be a default export, or a named export with the name `embeddedOverrides`.
|
|
1011
|
+
In a json file, the root is the array of objects. In a JavaScript/TypeScript file, the array of objects should be a default export, or a named export with the name `embeddedOverrides`.
|
|
523
1012
|
|
|
524
1013
|
An example `.json`/`.jsonc` file is:
|
|
525
1014
|
|
|
526
1015
|
```json
|
|
527
1016
|
[
|
|
528
1017
|
{
|
|
529
|
-
"
|
|
1018
|
+
"comments": ["sql"],
|
|
530
1019
|
"options": {
|
|
531
1020
|
"keywordCase": "lower"
|
|
532
1021
|
}
|
|
533
1022
|
},
|
|
534
1023
|
{
|
|
535
|
-
"
|
|
1024
|
+
"tags": ["mysql"],
|
|
536
1025
|
"options": {
|
|
537
1026
|
"keywordCase": "upper"
|
|
538
1027
|
}
|
|
@@ -542,7 +1031,7 @@ An example `.json`/`.jsonc` file is:
|
|
|
542
1031
|
|
|
543
1032
|
> [!CAUTION]
|
|
544
1033
|
>
|
|
545
|
-
> Please note that not every option is supported to override. That largely depends on at which phase those options will kick in and take effect. For example, you can't override `tabWidth` in `embeddedOverrides` because this option is used in the [`printDocToString`](https://github.com/prettier/prettier/blob/7aecca5d6473d73f562ca3af874831315f8f2581/src/document/printer.js#L302) phase, where `prettier-plugin-embed` cannot override this option for only a set of specified
|
|
1034
|
+
> Please note that not every option is supported to override. That largely depends on at which phase those options will kick in and take effect. For example, you can't override `tabWidth` in `embeddedOverrides` because this option is used in the [`printDocToString`](https://github.com/prettier/prettier/blob/7aecca5d6473d73f562ca3af874831315f8f2581/src/document/printer.js#L302) phase, where `prettier-plugin-embed` cannot override this option for only a set of specified comments or tags. To find the list of unsupported options, please check the interface definition of `EmbeddedOverride` in the [source code](https://github.com/Sec-ant/prettier-plugin-embed/blob/main/src/types.ts).
|
|
546
1035
|
|
|
547
1036
|
### Typed Options
|
|
548
1037
|
|
|
@@ -597,7 +1086,7 @@ There're several ways to use the typed options provided by this plugin. Taking t
|
|
|
597
1086
|
* @type {import("prettier-plugin-embed").PluginEmbedOptions}
|
|
598
1087
|
*/
|
|
599
1088
|
const pluginEmbedOptions = {
|
|
600
|
-
|
|
1089
|
+
embeddedSqlTags: ["sql"],
|
|
601
1090
|
};
|
|
602
1091
|
|
|
603
1092
|
/**
|