@platformos/prettier-plugin-liquid 0.0.6 → 0.0.8
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/dist/constants.evaluate.js +0 -3
- package/dist/plugin.js +0 -12
- package/dist/printer/embed.js +6 -12
- package/dist/printer/preprocess/augment-with-css-properties.js +6 -2
- package/dist/printer/preprocess/augment-with-siblings.d.ts +88 -146
- package/dist/printer/preprocess/index.d.ts +1 -1
- package/dist/printer/print/children.d.ts +1 -1
- package/dist/printer/print/liquid.d.ts +1 -1
- package/dist/printer/print/liquid.js +2 -11
- package/dist/printer/printer-liquid-html.js +50 -29
- package/dist/types.d.ts +0 -1
- package/package.json +6 -5
- package/standalone.js +1307 -1170
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AUGMENTATION_PIPELINE: import("../../types").Augment<import("../../types").
|
|
1
|
+
export declare const AUGMENTATION_PIPELINE: import("../../types").Augment<import("../../types").WithSiblings>[];
|
|
@@ -3,4 +3,4 @@ import { AstPath, LiquidHtmlNode, LiquidParserOptions, LiquidPrinter, LiquidPrin
|
|
|
3
3
|
export type HasChildren = Extract<LiquidHtmlNode, {
|
|
4
4
|
children?: LiquidHtmlNode[];
|
|
5
5
|
}>;
|
|
6
|
-
export declare function printChildren(path: AstPath<HasChildren>, options: LiquidParserOptions, print: LiquidPrinter, args: LiquidPrinterArgs): (doc.builders.BreakParent | (string | any[] | doc.builders.
|
|
6
|
+
export declare function printChildren(path: AstPath<HasChildren>, options: LiquidParserOptions, print: LiquidPrinter, args: LiquidPrinterArgs): (doc.builders.BreakParent | (string | any[] | doc.builders.Line | doc.builders.Align | doc.builders.BreakParent | doc.builders.Cursor | doc.builders.Fill | doc.builders.Group | doc.builders.IfBreak | doc.builders.Indent | doc.builders.IndentIfBreak | doc.builders.Label | doc.builders.LineSuffix | doc.builders.LineSuffixBoundary | doc.builders.Trim)[])[];
|
|
@@ -6,7 +6,7 @@ export declare function printLiquidBlockStart(path: AstPath<LiquidTag | LiquidBr
|
|
|
6
6
|
export declare function printLiquidBlockEnd(path: AstPath<LiquidTag>, _options: LiquidParserOptions, _print: LiquidPrinter, args?: LiquidPrinterArgs): Doc;
|
|
7
7
|
export declare function printLiquidTag(path: AstPath<LiquidTag>, options: LiquidParserOptions, print: LiquidPrinter, args: LiquidPrinterArgs): Doc;
|
|
8
8
|
export declare function printLiquidRawTag(path: AstPath<LiquidRawTag>, options: LiquidParserOptions, print: LiquidPrinter, { isLiquidStatement }: LiquidPrinterArgs): Doc;
|
|
9
|
-
export declare function printLiquidDoc(path: AstPath<RawMarkup>, _options: LiquidParserOptions, print: LiquidPrinter, _args: LiquidPrinterArgs): (doc.builders.
|
|
9
|
+
export declare function printLiquidDoc(path: AstPath<RawMarkup>, _options: LiquidParserOptions, print: LiquidPrinter, _args: LiquidPrinterArgs): (doc.builders.Hardline | doc.builders.Indent)[];
|
|
10
10
|
export declare function printLiquidDocParam(path: AstPath<LiquidDocParamNode>, options: LiquidParserOptions, _print: LiquidPrinter, _args: LiquidPrinterArgs): Doc;
|
|
11
11
|
export declare function printLiquidDocExample(path: AstPath<LiquidDocExampleNode>, options: LiquidParserOptions, _print: LiquidPrinter, _args: LiquidPrinterArgs): Doc;
|
|
12
12
|
export declare function printLiquidDocDescription(path: AstPath<LiquidDocDescriptionNode>, options: LiquidParserOptions, _print: LiquidPrinter, _args: LiquidPrinterArgs): Doc;
|
|
@@ -112,9 +112,7 @@ function printNamedLiquidBlockStart(path, _options, print, args, whitespaceStart
|
|
|
112
112
|
]);
|
|
113
113
|
}
|
|
114
114
|
case liquid_html_parser_1.NamedTags.content_for: {
|
|
115
|
-
|
|
116
|
-
const trailingWhitespace = markup.args.length > 0 ? line : ' ';
|
|
117
|
-
return tag(trailingWhitespace);
|
|
115
|
+
return tag(' ');
|
|
118
116
|
}
|
|
119
117
|
case liquid_html_parser_1.NamedTags.include:
|
|
120
118
|
case liquid_html_parser_1.NamedTags.render: {
|
|
@@ -135,11 +133,7 @@ function printNamedLiquidBlockStart(path, _options, print, args, whitespaceStart
|
|
|
135
133
|
case liquid_html_parser_1.NamedTags.capture:
|
|
136
134
|
case liquid_html_parser_1.NamedTags.increment:
|
|
137
135
|
case liquid_html_parser_1.NamedTags.decrement:
|
|
138
|
-
case liquid_html_parser_1.NamedTags.layout:
|
|
139
|
-
case liquid_html_parser_1.NamedTags.section: {
|
|
140
|
-
return tag(' ');
|
|
141
|
-
}
|
|
142
|
-
case liquid_html_parser_1.NamedTags.sections: {
|
|
136
|
+
case liquid_html_parser_1.NamedTags.layout: {
|
|
143
137
|
return tag(' ');
|
|
144
138
|
}
|
|
145
139
|
case liquid_html_parser_1.NamedTags.form: {
|
|
@@ -151,9 +145,6 @@ function printNamedLiquidBlockStart(path, _options, print, args, whitespaceStart
|
|
|
151
145
|
const trailingWhitespace = node.markup.reversed || node.markup.args.length > 0 ? line : ' ';
|
|
152
146
|
return tag(trailingWhitespace);
|
|
153
147
|
}
|
|
154
|
-
case liquid_html_parser_1.NamedTags.paginate: {
|
|
155
|
-
return tag(line);
|
|
156
|
-
}
|
|
157
148
|
case liquid_html_parser_1.NamedTags.if:
|
|
158
149
|
case liquid_html_parser_1.NamedTags.elsif:
|
|
159
150
|
case liquid_html_parser_1.NamedTags.unless: {
|
|
@@ -154,12 +154,7 @@ function printNode(path, options, print, args = {}) {
|
|
|
154
154
|
if (isRawMarkupIdentationSensitive()) {
|
|
155
155
|
return [node.value.trimEnd(), hardline];
|
|
156
156
|
}
|
|
157
|
-
const
|
|
158
|
-
const shouldNotIndentBody = parentNode &&
|
|
159
|
-
parentNode.type === liquid_html_parser_1.NodeTypes.LiquidRawTag &&
|
|
160
|
-
parentNode.name === 'schema' &&
|
|
161
|
-
!options.indentSchema;
|
|
162
|
-
const shouldIndentBody = node.kind !== liquid_html_parser_1.RawMarkupKinds.markdown && !shouldNotIndentBody;
|
|
157
|
+
const shouldIndentBody = node.kind !== liquid_html_parser_1.RawMarkupKinds.markdown;
|
|
163
158
|
const lines = (0, utils_2.bodyLines)(node.value);
|
|
164
159
|
const rawFirstLineIsntIndented = !!node.value.split(/\r?\n/)[0]?.match(/\S/);
|
|
165
160
|
const shouldSkipFirstLine = rawFirstLineIsntIndented;
|
|
@@ -220,7 +215,21 @@ function printNode(path, options, print, args = {}) {
|
|
|
220
215
|
];
|
|
221
216
|
}
|
|
222
217
|
case liquid_html_parser_1.NodeTypes.AssignMarkup: {
|
|
223
|
-
|
|
218
|
+
const doc = [node.name];
|
|
219
|
+
if (node.lookups.length > 0) {
|
|
220
|
+
const lookups = path.map((lookupPath) => {
|
|
221
|
+
const lookup = lookupPath.getValue();
|
|
222
|
+
if (lookup.type === liquid_html_parser_1.NodeTypes.String &&
|
|
223
|
+
/^\D/.test(lookup.value) &&
|
|
224
|
+
/^[a-z0-9_]+\??$/i.test(lookup.value)) {
|
|
225
|
+
return ['.', print(lookupPath)];
|
|
226
|
+
}
|
|
227
|
+
return ['[', print(lookupPath), ']'];
|
|
228
|
+
}, 'lookups');
|
|
229
|
+
doc.push(...lookups);
|
|
230
|
+
}
|
|
231
|
+
doc.push(` ${node.operator} `, path.call((p) => print(p), 'value'));
|
|
232
|
+
return doc;
|
|
224
233
|
}
|
|
225
234
|
case liquid_html_parser_1.NodeTypes.HashAssignMarkup: {
|
|
226
235
|
return [
|
|
@@ -251,29 +260,8 @@ function printNode(path, options, print, args = {}) {
|
|
|
251
260
|
}
|
|
252
261
|
return doc;
|
|
253
262
|
}
|
|
254
|
-
case liquid_html_parser_1.NodeTypes.PaginateMarkup: {
|
|
255
|
-
const doc = [
|
|
256
|
-
path.call((p) => print(p), 'collection'),
|
|
257
|
-
line,
|
|
258
|
-
'by ',
|
|
259
|
-
path.call((p) => print(p), 'pageSize'),
|
|
260
|
-
];
|
|
261
|
-
if (node.args.length > 0) {
|
|
262
|
-
doc.push([
|
|
263
|
-
',',
|
|
264
|
-
line,
|
|
265
|
-
join([',', line], path.map((p) => print(p), 'args')),
|
|
266
|
-
]);
|
|
267
|
-
}
|
|
268
|
-
return doc;
|
|
269
|
-
}
|
|
270
263
|
case liquid_html_parser_1.NodeTypes.ContentForMarkup: {
|
|
271
|
-
|
|
272
|
-
const doc = [contentForType];
|
|
273
|
-
if (node.args.length > 0) {
|
|
274
|
-
doc.push(',', line, join([',', line], path.map((p) => print(p), 'args')));
|
|
275
|
-
}
|
|
276
|
-
return doc;
|
|
264
|
+
return path.call((p) => print(p), 'contentForType');
|
|
277
265
|
}
|
|
278
266
|
case liquid_html_parser_1.NodeTypes.RenderMarkup: {
|
|
279
267
|
const snippet = path.call((p) => print(p), 'snippet');
|
|
@@ -508,6 +496,39 @@ function printNode(path, options, print, args = {}) {
|
|
|
508
496
|
case liquid_html_parser_1.NodeTypes.LiquidDocPromptNode: {
|
|
509
497
|
return (0, liquid_1.printLiquidDocPrompt)(path, options, print, args);
|
|
510
498
|
}
|
|
499
|
+
case liquid_html_parser_1.NodeTypes.JsonHashLiteral: {
|
|
500
|
+
if (node.entries.length === 0)
|
|
501
|
+
return '{}';
|
|
502
|
+
return group([
|
|
503
|
+
'{',
|
|
504
|
+
indent([
|
|
505
|
+
line,
|
|
506
|
+
join([',', line], path.map((p) => print(p), 'entries')),
|
|
507
|
+
]),
|
|
508
|
+
line,
|
|
509
|
+
'}',
|
|
510
|
+
]);
|
|
511
|
+
}
|
|
512
|
+
case liquid_html_parser_1.NodeTypes.JsonKeyValuePair: {
|
|
513
|
+
return [
|
|
514
|
+
path.call((p) => print(p), 'key'),
|
|
515
|
+
': ',
|
|
516
|
+
path.call((p) => print(p), 'value'),
|
|
517
|
+
];
|
|
518
|
+
}
|
|
519
|
+
case liquid_html_parser_1.NodeTypes.JsonArrayLiteral: {
|
|
520
|
+
if (node.elements.length === 0)
|
|
521
|
+
return '[]';
|
|
522
|
+
return group([
|
|
523
|
+
'[',
|
|
524
|
+
indent([
|
|
525
|
+
line,
|
|
526
|
+
join([',', line], path.map((p) => print(p), 'elements')),
|
|
527
|
+
]),
|
|
528
|
+
line,
|
|
529
|
+
']',
|
|
530
|
+
]);
|
|
531
|
+
}
|
|
511
532
|
default: {
|
|
512
533
|
return (0, utils_1.assertNever)(node);
|
|
513
534
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export type LiquidParserOptions = ParserOptions<LiquidHtmlNode> & {
|
|
|
12
12
|
singleLineLinkTags: boolean;
|
|
13
13
|
liquidSingleQuote: boolean;
|
|
14
14
|
embeddedSingleQuote: boolean;
|
|
15
|
-
indentSchema: boolean;
|
|
16
15
|
captureWhitespaceSensitivity: 'strict' | 'ignore';
|
|
17
16
|
liquidDocParamDash: boolean;
|
|
18
17
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformos/prettier-plugin-liquid",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Prettier Liquid/HTML plugin for platformOS",
|
|
5
5
|
"author": "platformOS",
|
|
6
6
|
"homepage": "https://github.com/Platform-OS/platformos-tools/tree/master/packages/prettier-plugin-liquid#readme",
|
|
@@ -51,15 +51,16 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/prettier": "^2.4.2",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
54
|
+
"prettier": "npm:prettier@^2.6.1",
|
|
55
|
+
"cross-env": "^10.1.0",
|
|
56
|
+
"module-alias": "^2.3.4",
|
|
56
57
|
"prettier2": "npm:prettier@^2.6.1",
|
|
57
58
|
"prettier3": "npm:prettier@^3.0.0",
|
|
58
59
|
"source-map-support": "^0.5.21",
|
|
59
|
-
"tsconfig-paths": "^
|
|
60
|
+
"tsconfig-paths": "^4.2.0"
|
|
60
61
|
},
|
|
61
62
|
"dependencies": {
|
|
62
|
-
"@platformos/liquid-html-parser": "^0.0.
|
|
63
|
+
"@platformos/liquid-html-parser": "^0.0.8",
|
|
63
64
|
"html-styles": "^1.0.0"
|
|
64
65
|
}
|
|
65
66
|
}
|