@platformos/prettier-plugin-liquid 0.0.7 → 0.0.9
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 +0 -1
- package/dist/constants.evaluate.js +0 -3
- package/dist/plugin.js +0 -6
- package/dist/printer/embed.js +4 -9
- package/dist/printer/preprocess/augment-with-css-properties.js +8 -2
- package/dist/printer/preprocess/augment-with-siblings.d.ts +98 -144
- package/dist/printer/print/liquid.js +6 -12
- package/dist/printer/printer-liquid-html.js +57 -29
- package/dist/types.d.ts +0 -1
- package/package.json +2 -2
- package/standalone.js +319 -215
- package/standalone.d.ts +0 -2
|
@@ -93,7 +93,10 @@ function printNamedLiquidBlockStart(path, _options, print, args, whitespaceStart
|
|
|
93
93
|
return tag(trailingWhitespace);
|
|
94
94
|
}
|
|
95
95
|
case liquid_html_parser_1.NamedTags.assign: {
|
|
96
|
-
const
|
|
96
|
+
const valueFilters = node.markup.value.type === liquid_html_parser_1.NodeTypes.AssignPushRhs
|
|
97
|
+
? node.markup.value.pushValue.filters
|
|
98
|
+
: node.markup.value.filters;
|
|
99
|
+
const trailingWhitespace = valueFilters.length > 0 ? line : ' ';
|
|
97
100
|
return tag(trailingWhitespace);
|
|
98
101
|
}
|
|
99
102
|
case liquid_html_parser_1.NamedTags.hash_assign: {
|
|
@@ -112,9 +115,7 @@ function printNamedLiquidBlockStart(path, _options, print, args, whitespaceStart
|
|
|
112
115
|
]);
|
|
113
116
|
}
|
|
114
117
|
case liquid_html_parser_1.NamedTags.content_for: {
|
|
115
|
-
|
|
116
|
-
const trailingWhitespace = markup.args.length > 0 ? line : ' ';
|
|
117
|
-
return tag(trailingWhitespace);
|
|
118
|
+
return tag(' ');
|
|
118
119
|
}
|
|
119
120
|
case liquid_html_parser_1.NamedTags.include:
|
|
120
121
|
case liquid_html_parser_1.NamedTags.render: {
|
|
@@ -135,11 +136,7 @@ function printNamedLiquidBlockStart(path, _options, print, args, whitespaceStart
|
|
|
135
136
|
case liquid_html_parser_1.NamedTags.capture:
|
|
136
137
|
case liquid_html_parser_1.NamedTags.increment:
|
|
137
138
|
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: {
|
|
139
|
+
case liquid_html_parser_1.NamedTags.layout: {
|
|
143
140
|
return tag(' ');
|
|
144
141
|
}
|
|
145
142
|
case liquid_html_parser_1.NamedTags.form: {
|
|
@@ -151,9 +148,6 @@ function printNamedLiquidBlockStart(path, _options, print, args, whitespaceStart
|
|
|
151
148
|
const trailingWhitespace = node.markup.reversed || node.markup.args.length > 0 ? line : ' ';
|
|
152
149
|
return tag(trailingWhitespace);
|
|
153
150
|
}
|
|
154
|
-
case liquid_html_parser_1.NamedTags.paginate: {
|
|
155
|
-
return tag(line);
|
|
156
|
-
}
|
|
157
151
|
case liquid_html_parser_1.NamedTags.if:
|
|
158
152
|
case liquid_html_parser_1.NamedTags.elsif:
|
|
159
153
|
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,46 @@ 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
|
+
}
|
|
532
|
+
case liquid_html_parser_1.NodeTypes.AssignPushRhs: {
|
|
533
|
+
return [
|
|
534
|
+
path.call((p) => print(p), 'pushSource'),
|
|
535
|
+
' << ',
|
|
536
|
+
path.call((p) => print(p), 'pushValue'),
|
|
537
|
+
];
|
|
538
|
+
}
|
|
511
539
|
default: {
|
|
512
540
|
return (0, utils_1.assertNever)(node);
|
|
513
541
|
}
|
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.9",
|
|
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",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"tsconfig-paths": "^4.2.0"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@platformos/liquid-html-parser": "^0.0.
|
|
63
|
+
"@platformos/liquid-html-parser": "^0.0.9",
|
|
64
64
|
"html-styles": "^1.0.0"
|
|
65
65
|
}
|
|
66
66
|
}
|