This repository has been archived by the owner on Mar 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
markup.d.ts
679 lines (661 loc) Β· 16.6 KB
/
markup.d.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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
export interface MarkupOptions {
/**
* **Default** `false`
*
* ππ½ββοΈ Recommended setting is: `false`
*
* Automatically correct some sloppiness in code and allow Prettify to
* reason with the intended structures in order to reduce chaos in otherwise
* unreadble and terrible code.
*
* _The option enables Prettify to go about fixing code. It's not
* going to produce miracles and for the most part it will have little effect
* overall but can help in some situations._
*
* ---
*/
correct?: boolean;
/**
* **Default** `preserve`
*
* ππ½ββοΈ Recommended setting is: `preserve`
*
* How attribute keys and value casing should be processed. This defaults to `preserve`
* which will leave casing intact and _typically_ the best option to use. Accepts one
* of the following options:
*
* - `preserve`
* - `lowercase`
* - `lowercase-name`
* - `lowercase-value`
*
* ---
*
* #### Preserve Example
*
* *Below is an example of how this rule works when it is set to `preserve`. This is
* the default and the safest option to use.*
*
* ```html
*
* <!-- Before Formatting -->
* <div dAtA-AtTr="FoO-bAr"></div>
*
* <!-- After Formatting -->
* <div dAtA-AtTr="FoO-bAr"></div>
*
* ```
*
* ---
*
* #### Lowercase Example
*
* *Below is an example of how this rule work it it's set to `lowercase`. This might
* be problematic to use projects where casing needs to be respected as both attribute
* names and values will be converted to lowercase*
*
* ```html
*
* <!-- Before Formatting -->
* <div DATA-ATTR="FOO-BAR"></div>
*
* <!-- After Formatting -->
* <div data-attr="foo-bar"></div>
*
* ```
*
* ---
*
* #### Lowercase Name Example
*
* *Below is an example of how this rule work it it's set to `lowercase-name`. This will
* ensure the the attribute names are always converted to lowercase*
*
* ```html
*
* <!-- Before Formatting -->
* <div DATA-ATTR="FOO-BAR"></div>
*
* <!-- After Formatting -->
* <div class="FOO-BAR"></div>
*
* ```
*
* ---
*
* #### Lowercase Value Example
*
* *Below is an example of how this rule work it it's set to `lowercase-value`. This will
* ensure the the attribute values are always converted to lowercase*
*
* ```html
*
* <!-- Before Formatting -->
* <div DATA-ATTR="FOO-BAR"></div>
*
* <!-- After Formatting -->
* <div DATA-ATTR="foo-bar"></div>
*
* ```
*/
attributeCasing?: 'preserve' | 'lowercase' | 'lowercase-name' | 'lowercase-value';
/**
* **Default** `false`
*
* ππ½ββοΈ Recommended setting is: `false`
*
* HTML Attribute sorting. When enabled it will sort attributes
* alphabetically. Attribute sorting is ignored on tags that contain
* template attributes.
*
* ---
*
* #### Example
*
* *Below is an example of how this rule works if it's enabled, ie: `true`. Notice
* how the attributes are not alphabetically sorted before formatting is applied
* whereas after formatting they are sorted alphabetically.*
*
* ```html
*
* <!-- Before formatting -->
* <div
* id="x"
* data-b="100"
* data-a="foo"
* data-c="x"
* class="xx">
*
* </div>
*
* <!-- After formatting -->
* <div
* class="xx"
* data-a="foo"
* data-b="100"
* data-c="x"
* id="x">
*
* </div>
* ```
*/
attributeSort?: boolean;
/**
* **Default** `[]`
*
* ππ½ββοΈ Recommended setting is: `[]`
*
* A comma separated list of attribute names. Attributes will be sorted according to
* this list and then alphanumerically. This option requires `attributeSort` have
* to be enabled, ie: have a value of `true`.
*
* ---
*
* #### Example
*
* *Below is an example of how this rule works if it's enabled and you've defined
* the following attribute sorting structure:*
*
* ```js
* {
* attributeSort: true, // Must be true when using this rule
* attributeSortList: ['id', 'class', 'data-b']
* }
* ```
*
* *Using the above options, notice how how `data-a`, `data-c` and `data-d` are sorted
* alphabetically in order following the sort list we provided*
*
* ```html
*
* <!-- Before formatting -->
* <div
* data-a
* id="x"
* data-d
* data-c
* data-b
* class="xx">
*
* </div>
*
* <!-- After formatting -->
* <div
* id="x"
* class="xx"
* data-b
* data-a
* data-c
* data-d>
*
* </div>
* ```
*/
attributeSortList?: string[];
/**
* **Default** `false`
*
* ππ½ββοΈ Recommended setting is: `true`
*
* If a blank new line should be forced above comments.
*/
commentNewline?: boolean;
/**
* **Default** `preserve`
*
* ππ½ββοΈ Recommended setting is: `tags`
*
* How delimiter whitespace trim dashes should handled on
* Liquid tokens. You should avoid setting this to `force` in order to
* avoid stripping whitespace between text content. The rule accepts one
* of the following options:
*
* - `preserve`
* - `strip`
* - `force`
* - `tags`
* - `outputs`
*
* ---
*
* #### Preserve Example
*
* *Below is an example of how this rule works if set to `preserve` which is
* the default and leaves all occurances of trims intact*
*
* ```liquid
*
* <!-- Before formatting -->
* {% if x -%}
* {{- foo_bar }} {{- trims }}
* {% endof -%}
*
* <!-- Before formatting -->
* {% if x -%}
* {{- foo_bar }} {{- trims }}
* {% endof -%}
* ```
*
* ---
*
* #### Strip Example
*
* *Below is an example of how this rule works if set to `strip` which will
* remove all occurances of trims from Liquid tokens.*
*
* ```liquid
*
* <!-- Before formatting -->
* {%- if x -%}
* {{- foo_bar -}}
* {%- endof -%}
*
* <!-- Before formatting -->
* {% if x %}
* {{ foo_bar }}
* {% endof %}
*
* ```
*
* ---
*
* #### Force Example
*
* *Below is an example of how this rule works if set to `force` which will
* apply trims on all Liquid tokens.*
*
* ```liquid
*
* <!-- Before formatting -->
* {% if x %}
* {{ foo_bar }}
* {% endof %}
*
* <!-- Before formatting -->
* {%- if x -%}
* {{- foo_bar -}}
* {%- endof -%}
*
* ```
*
*
* ---
*
* #### Tags Example
*
* *Below is an example of how this rule works if set to `tags` which will
* apply trims to Liquid tag tokens but leave object output tokens intact.*
*
* ```liquid
*
* <!-- Before formatting -->
* {% if x %}
* {{ foo_bar -}} {{ no_trims }}
* {% endof %}
*
* <!-- After formatting -->
* {%- if x -%}
* {{ foo_bar -}} {{ no_trims }}
* {%- endof -%}
*
* ```
*
* ---
*
* #### Outputs Example
*
* *Below is an example of how this rule works if set to `outputs` which will
* apply trims to Liquid object output tokens but leave tag tokens intact.*
*
* ```liquid
*
* <!-- Before formatting -->
* {% if x -%}
* {{ foo_bar }} {{ trims }}
* {%- endof %}
*
* <!-- After formatting -->
* {% if x -%}
* {{- foo_bar -}} {{- trims -}}
* {%- endof %}
*
* ```
*/
delimiterTrims?: 'preserve' | 'strip' | 'force' | 'tags' | 'outputs';
/**
* **Default** `true`
*
* ππ½ββοΈ Recommended setting is: `true`
*
* Whether or not to normalize and correct the inner spacing of Liquid tokens.
* This rules will equally distribute whitespace characters contained within
* Liquid tags and output tokens.
*
* **Note**
*
* Normalized spacing does not strip newline characters or code wrapped in quotation
* characters (strings) from the inner contents of Liquid tokens.
*
* ---
*
* #### Example
*
* *Below is an example of how this rule works if it's enabled, ie: `true` which is the default.
* Notice how in the below example, all string tokens are left intact whereas other tokens will
* normalize the whitespace distribution*
*
*
* ```liquid
*
* <!-- Before formatting -->
* {{ object.prop |filter:'x' , 'xx'| filter : 'preserves strings' }}
* {% assign 'foo ' = ' x ' | append : object . prop %}
*
* <!-- After formatting -->
*
* {{ object.prop | filter: 'x', 'xx' | filter: 'preserves strings' }}
*
* {% assign 'foo ' = ' preserved ' | append: object.prop %}
* ```
*/
normalizeSpacing?: boolean;
/**
* **Default** `false`
*
* ππ½ββοΈ Recommended setting is: `true`
*
* Markup self-closing tags end will end with `' />'` instead of `'/>'`
*
* ---
*
* #### Example
*
* *Below is an example of how this rule works if it's enabled, ie: `true`*
*
*
* ```html
*
* <!-- Before formatting -->
* <picture>
* <path srcset="."/>
* </picture>
*
* <!-- After formatting - Notice the the space insertion applied -->
* <picture>
* <path srcset="." />
* </picture>
*
* ```
*/
selfCloseSpace?: boolean;
/**
* **Default** `false`
*
* ππ½ββοΈ Recommended setting is: `false`
*
* If text in the provided markup code should be preserved exactly as provided.
* This option eliminates beautification and wrapping of text content.
*/
preserveText?: boolean;
/**
* **Default** `false`
*
* ππ½ββοΈ Recommended setting is: `3`
*
* If all markup attributes should be indented each onto their own line. You
* can optionally provide an integer value of `1` or more. When an integer value
* is passed, attributes will be forced only if the number of attributes contained
* on the tag exceeds the supplied value limit. When you define a `wrap` level then
* attributes will be automatically forced. This is typically a better solution than
* forcing all attributes onto newlines or an even better solution would be to set
* a limit level.
*
* ---
*
* #### Disabled Example
*
* *Below is the default, wherein attributes are only forced when wrap is exceeded.*
*
* ```html
*
* <div class="x" id="{{ foo }}" data-x="xx">
*
* </div>
*
* ```
*
* ---
*
* #### Enabled Example
*
* *Below is an example of how this rule works if it's enabled, ie: `true`*
*
* ```html
*
* <div
* class="x"
* id="{{ foo }}"
* data-x="xx">
*
* </div>
*
* ```
*
* ---
*
* #### Limit Example
*
* *Below we provide a value of `2` so formatting will be applied as such:*
*
* ```html
*
* <!-- Tag contains 2 attributes, they will not be forced-->
* <div class="x" id="{{ foo }}">
*
* </div>
*
* <!-- Tag contains 3 attributes, thus they will be forced -->
* <div
* class="x"
* id="{{ foo }}"
* data-x="xx">
*
* </div>
*
* <!-- Tag contains 1 attribute, it will not be forced-->
* <div class="x">
*
* </div>
*
* ```
*/
forceAttribute?: boolean | number;
/**
* **Default** `false`
*
* ππ½ββοΈ Recommended setting is: `true`
*
* Whether the leading attribute should be forced onto a newline when
* word `wrap` limit is exceeded or if it should be preserved. By default,
* Prettify preserves the leading attribute when applying wrap indentation.
* Enabling this option will force indent all attributes if wrap is exceeded.
*
* This rule requires a `wrap` level to be defined. If you have `forceAttribute`
* enabled or using a force attribute limit value it will override this option.
* If you desire wrap based attribute indentation, set `forceAttribute` to `false`
* and ensure a `wrap` level is defined.
*
* ---
*
* #### Disabled (default)
*
* *Below is an example of how this rule works if it's disabled (ie: `false`) and
* attributes have exceeded a defined wrap limit. Notice how leading attributes
* are preserved that have not exceeded wrap, but proceeding attributes are indented
* onto their own lines, this is the default behaviour Prettify uses.*
*
* ```html
*
* <!-- Leading attribute is preserved -->
* <div class="x"
* id="{{ foo }}"
* data-attribute-example="100"
* data-x="xx">
*
* </div>
*
* ```
*
* #### Enabled
*
* *Below is an example of how this rule works if it's enabled (ie: `true`) and
* attributes have exceeded the defined wrap limit. Notice how all attributes
* and indented onto their own line, including the leading attribute.*
*
*
* ```html
*
* <!-- All attributes are forced including the leading attribute -->
* <div
* class="x"
* id="{{ foo }}"
* data-attribute-example="100"
* data-x="xx">
*
* </div>
*
* ```
*/
forceLeadAttribute?: boolean | number;
/**
* **Default** `false`
*
* ππ½ββοΈ Recommended setting is: `true`
*
* Will force indentation upon all content and tags without regard for the
* text nodes.
*
* ---
*
* #### Example
*
* *Below is an example of how this rule works if it's enabled, ie: `true`*
*
*
* ```html
*
* <!-- Before Formatting -->
* <ul>
* <li>Hello</li>
* <li>World</li>
* </ul>
*
* <!-- After formatting -->
* <ul>
* <li>
* Hello
* </li>
* <li>
* World
* </li>
* </ul>
* ```
*/
forceIndent?: boolean;
/**
* **Default** `none`
*
* ππ½ββοΈ Recommended setting is: `double`
*
* If the quotes of markup attributes should be converted to single quotes
* or double quotes. Don't be a fucking hero with this option. Markup content
* should use double quotations, it's the standard.
*
* **Options**
*
* - `double` Converts single quotes to double quotes
* - `none` Ignores this option (default)
* - `single` Converts double quotes to single quotes
*/
quoteConvert?: 'double' | 'single' | 'none';
/**
* **Default** `false`
*
* ππ½ββοΈ Recommended setting is: `false`
*
* If markup tags should have their insides preserved.
* This option is only available to markup and does not support
* child tokens that require a different lexer. When enabled, this
* rule will override and run precedence for all attribute related rules.
*
*
* ---
*
* #### Example
*
* *Below is an example of how this rule works if it's enabled, ie: `true`.
* There is no difference between the _before_ and _after_ version of the code
* when this option is enabled.*
*
* ```html
*
* <!-- Before Formatting -->
* <div
* id="x" data-x="foo"
* class="xx"></div>
*
* <!-- After Formatting -->
* <div
* id="x" data-x="foo"
* class="xx"></div>
*
* ```
*/
preserveAttributes?: boolean;
/**
* **Default** `default`
*
* ππ½ββοΈ Recommended setting is: `before`
*
* Controls the placement of Liquid tag operator type characters in newline structures.
* In situations where you write a multiline tag expression this rule can augment the
* order of leading operator characters such as the parameter comma `,` separator.
*/
lineBreakSeparator?: 'default' | 'before' | 'after';
/**
* **Default** `false`
*
* ππ½ββοΈ Recommended setting is: `false`
*
* Whether HTML and Liquid tags identified to be containing CSS or SCSS
* should be ignored from beautification. When enabled, formatting will
* be applied in accordance with rules defined in the `style` lexer.
*
*/
ignoreStyles?: boolean;
/**
* **Default** `true`
*
* ππ½ββοΈ Recommended setting is: `false`
*
* Whether HTML and Liquid tags identified to be containing JavaScript
* should be ignored from beautification. When enabled, formatting will
* be applied in accordance with rules defined in the `script` lexer.
*
* _This rules is currently set to `true` by default as JavaScript formatting
* is not yet production ready, but still operational to an extent. Enable at
* your on discretion_
*
*/
ignoreScripts?: boolean;
/**
* **Default** `intent`
*
* ππ½ββοΈ Recommended setting is: `intent`
*
* Controls force indentation applied in accordance with the attribute value expressions.
* This rule is Liquid specific.
*
*/
valueForce?: 'wrap' | 'newline' | 'intent' | 'always' | 'never';
}