@platformos/liquid-html-parser 0.0.16 → 0.0.18
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/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/stage-1-cst.js +0 -2
- package/grammar/liquid-html.ohm +30 -16
- package/grammar/liquid-html.ohm.js +30 -16
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export * from './stage-2-ast';
|
|
|
2
2
|
export * from './types';
|
|
3
3
|
export * from './errors';
|
|
4
4
|
export { TAGS_WITHOUT_MARKUP, RAW_TAGS, VOID_ELEMENTS, BLOCKS } from './grammar';
|
|
5
|
+
export { LiquidLiteralValues } from './stage-1-cst';
|
|
5
6
|
export { getConditionalComment } from './conditional-comment';
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getConditionalComment = exports.BLOCKS = exports.VOID_ELEMENTS = exports.RAW_TAGS = exports.TAGS_WITHOUT_MARKUP = void 0;
|
|
17
|
+
exports.getConditionalComment = exports.LiquidLiteralValues = exports.BLOCKS = exports.VOID_ELEMENTS = exports.RAW_TAGS = exports.TAGS_WITHOUT_MARKUP = void 0;
|
|
18
18
|
__exportStar(require("./stage-2-ast"), exports);
|
|
19
19
|
__exportStar(require("./types"), exports);
|
|
20
20
|
__exportStar(require("./errors"), exports);
|
|
@@ -23,6 +23,8 @@ Object.defineProperty(exports, "TAGS_WITHOUT_MARKUP", { enumerable: true, get: f
|
|
|
23
23
|
Object.defineProperty(exports, "RAW_TAGS", { enumerable: true, get: function () { return grammar_1.RAW_TAGS; } });
|
|
24
24
|
Object.defineProperty(exports, "VOID_ELEMENTS", { enumerable: true, get: function () { return grammar_1.VOID_ELEMENTS; } });
|
|
25
25
|
Object.defineProperty(exports, "BLOCKS", { enumerable: true, get: function () { return grammar_1.BLOCKS; } });
|
|
26
|
+
var stage_1_cst_1 = require("./stage-1-cst");
|
|
27
|
+
Object.defineProperty(exports, "LiquidLiteralValues", { enumerable: true, get: function () { return stage_1_cst_1.LiquidLiteralValues; } });
|
|
26
28
|
var conditional_comment_1 = require("./conditional-comment");
|
|
27
29
|
Object.defineProperty(exports, "getConditionalComment", { enumerable: true, get: function () { return conditional_comment_1.getConditionalComment; } });
|
|
28
30
|
//# sourceMappingURL=index.js.map
|
package/dist/stage-1-cst.js
CHANGED
|
@@ -613,8 +613,6 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
|
|
|
613
613
|
liquidTagResponseHeadersMarkup: 0,
|
|
614
614
|
liquidTagRollback: 0,
|
|
615
615
|
renderArguments: 1,
|
|
616
|
-
functionRenderArguments: 1,
|
|
617
|
-
functionTagArguments: 0,
|
|
618
616
|
completionModeRenderArguments: function (_0, namedArguments, _2, _3, _4, _5, variableLookup, _7) {
|
|
619
617
|
const self = this;
|
|
620
618
|
// variableLookup.sourceString can be '' when there are no incomplete params
|
package/grammar/liquid-html.ohm
CHANGED
|
@@ -220,7 +220,7 @@ Liquid <: Helpers {
|
|
|
220
220
|
liquidTagOpenBackground = liquidTagOpenRule<"background", liquidTagBackgroundInlineMarkup>
|
|
221
221
|
// Block form: only named arguments, no result variable (matches Ruby inline syntax)
|
|
222
222
|
// Use negative lookahead to exclude file-based syntax (with "=")
|
|
223
|
-
liquidTagBackgroundInlineMarkup = ~(variableSegment space* "=") argumentSeparatorOptionalComma tagArguments space*
|
|
223
|
+
liquidTagBackgroundInlineMarkup = ~(variableSegment space* "=") argumentSeparatorOptionalComma tagArguments (space* ",")? space*
|
|
224
224
|
|
|
225
225
|
liquidTagOpenCache = liquidTagOpenRule<"cache", liquidTagCacheMarkup>
|
|
226
226
|
liquidTagCacheMarkup = liquidExpression<delimTag> renderArguments
|
|
@@ -228,7 +228,7 @@ Liquid <: Helpers {
|
|
|
228
228
|
liquidTagOpenParseJson = liquidTagOpenRule<"parse_json", variableSegmentAsLookupMarkup>
|
|
229
229
|
|
|
230
230
|
liquidTagOpenTransaction = liquidTagOpenRule<"transaction", liquidTagOpenTransactionMarkup>
|
|
231
|
-
liquidTagOpenTransactionMarkup = tagArguments space*
|
|
231
|
+
liquidTagOpenTransactionMarkup = tagArguments (space* ",")? space*
|
|
232
232
|
|
|
233
233
|
liquidTagOpenTry = liquidTagOpenRule<"try", empty>
|
|
234
234
|
|
|
@@ -264,10 +264,10 @@ Liquid <: Helpers {
|
|
|
264
264
|
exportVariable = variableSegmentAsLookup ~(space* ":")
|
|
265
265
|
|
|
266
266
|
liquidTagContext = liquidTagRule<"context", liquidTagContextMarkup>
|
|
267
|
-
liquidTagContextMarkup = tagArguments space*
|
|
267
|
+
liquidTagContextMarkup = tagArguments (space* ",")? space*
|
|
268
268
|
|
|
269
269
|
liquidTagSignIn = liquidTagRule<"sign_in", liquidTagSignInMarkup>
|
|
270
|
-
liquidTagSignInMarkup = tagArguments space*
|
|
270
|
+
liquidTagSignInMarkup = tagArguments (space* ",")? space*
|
|
271
271
|
|
|
272
272
|
liquidTagRedirectTo = liquidTagRule<"redirect_to", liquidTagRedirectToMarkup>
|
|
273
273
|
liquidTagRedirectToMarkup = liquidExpression<delimTag> renderArguments
|
|
@@ -313,7 +313,12 @@ Liquid <: Helpers {
|
|
|
313
313
|
) endOfIdentifier
|
|
314
314
|
|
|
315
315
|
liquidTagOpenForm = liquidTagOpenRule<"form", liquidTagOpenFormMarkup>
|
|
316
|
-
|
|
316
|
+
// Matches the platformOS runtime (FormForTag): an optional positional model name first
|
|
317
|
+
// ({% form form, method: 'delete' %}), then key: value attributes. The runtime scans
|
|
318
|
+
// `[\w-]+: value` pairs out of the markup, so keys may contain hyphens (html-class:,
|
|
319
|
+
// html-data-user-id:), commas between attributes are optional, and bare {% form %} is valid.
|
|
320
|
+
liquidTagOpenFormMarkup =
|
|
321
|
+
orderedListOf<positionalArgument<delimTag>, namedArgument<delimTag>, argumentSeparatorOptionalComma> (space* ",")? space*
|
|
317
322
|
|
|
318
323
|
liquidTagOpenFor = liquidTagOpenRule<"for", liquidTagOpenForMarkup>
|
|
319
324
|
|
|
@@ -611,18 +616,27 @@ LiquidStatement <: Liquid {
|
|
|
611
616
|
liquidJsonHashLiteral<delim> := "{" (space | newline)* listOf<liquidJsonKeyValue<delim>, liquidJsonSep> (space | newline)* "}"
|
|
612
617
|
liquidJsonArrayLiteral<delim> := "[" (space | newline)* listOf<liquidJsonValue<delim>, liquidJsonSep> (space | newline)* "]"
|
|
613
618
|
|
|
614
|
-
//
|
|
615
|
-
//
|
|
616
|
-
//
|
|
617
|
-
//
|
|
618
|
-
//
|
|
619
|
+
// Inside {% liquid %} blocks, a tag's key:value argument list may span multiple lines.
|
|
620
|
+
// Every argument-list tag whose separator is argumentSeparatorOptionalComma — function,
|
|
621
|
+
// graphql, background, render, include, log, context, sign_in, transaction, cache, etc. —
|
|
622
|
+
// inherits this automatically; the base Liquid grammar keeps these horizontal-only outside
|
|
623
|
+
// {% liquid %}, so the standalone tag/block forms are unaffected (zero regression surface).
|
|
619
624
|
//
|
|
620
|
-
//
|
|
621
|
-
//
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
625
|
+
// A newline is only crossed AFTER a comma AND only when the next non-blank token is a
|
|
626
|
+
// named argument (`name:`). This mirrors the Ruby runtime's continuation guard
|
|
627
|
+
// (continuation_line? matches /\A[\w-]+\s*:/): a trailing comma followed by a new
|
|
628
|
+
// directive (another tag, an assign, an echo, a bare/positional value such as
|
|
629
|
+
// `log "second"`, …) does NOT look like `name:`, so the newline is not consumed, the list
|
|
630
|
+
// ends, and the comma is treated as a stylistic trailing comma — the next line stays a
|
|
631
|
+
// separate statement. This guard is essential for positional-accepting lists like log's,
|
|
632
|
+
// where a following directive would otherwise be swallowed as a positional argument.
|
|
633
|
+
//
|
|
634
|
+
// Both alternatives must have the same arity (3: space, comma, group) for Ohm's uniform-arity
|
|
635
|
+
// requirement and consistent visitor child indexing. The positive lookahead is written as
|
|
636
|
+
// ~(~(...)) so it contributes arity 0, keeping the first alternative's group at arity 3.
|
|
637
|
+
argumentSeparatorOptionalComma :=
|
|
638
|
+
space* "," ((space | newline)* ~(~(variableSegment space* ":")))
|
|
639
|
+
| space* ","? space*
|
|
626
640
|
}
|
|
627
641
|
|
|
628
642
|
LiquidDoc <: Helpers {
|
|
@@ -220,7 +220,7 @@ Liquid <: Helpers {
|
|
|
220
220
|
liquidTagOpenBackground = liquidTagOpenRule<"background", liquidTagBackgroundInlineMarkup>
|
|
221
221
|
// Block form: only named arguments, no result variable (matches Ruby inline syntax)
|
|
222
222
|
// Use negative lookahead to exclude file-based syntax (with "=")
|
|
223
|
-
liquidTagBackgroundInlineMarkup = ~(variableSegment space* "=") argumentSeparatorOptionalComma tagArguments space*
|
|
223
|
+
liquidTagBackgroundInlineMarkup = ~(variableSegment space* "=") argumentSeparatorOptionalComma tagArguments (space* ",")? space*
|
|
224
224
|
|
|
225
225
|
liquidTagOpenCache = liquidTagOpenRule<"cache", liquidTagCacheMarkup>
|
|
226
226
|
liquidTagCacheMarkup = liquidExpression<delimTag> renderArguments
|
|
@@ -228,7 +228,7 @@ Liquid <: Helpers {
|
|
|
228
228
|
liquidTagOpenParseJson = liquidTagOpenRule<"parse_json", variableSegmentAsLookupMarkup>
|
|
229
229
|
|
|
230
230
|
liquidTagOpenTransaction = liquidTagOpenRule<"transaction", liquidTagOpenTransactionMarkup>
|
|
231
|
-
liquidTagOpenTransactionMarkup = tagArguments space*
|
|
231
|
+
liquidTagOpenTransactionMarkup = tagArguments (space* ",")? space*
|
|
232
232
|
|
|
233
233
|
liquidTagOpenTry = liquidTagOpenRule<"try", empty>
|
|
234
234
|
|
|
@@ -264,10 +264,10 @@ Liquid <: Helpers {
|
|
|
264
264
|
exportVariable = variableSegmentAsLookup ~(space* ":")
|
|
265
265
|
|
|
266
266
|
liquidTagContext = liquidTagRule<"context", liquidTagContextMarkup>
|
|
267
|
-
liquidTagContextMarkup = tagArguments space*
|
|
267
|
+
liquidTagContextMarkup = tagArguments (space* ",")? space*
|
|
268
268
|
|
|
269
269
|
liquidTagSignIn = liquidTagRule<"sign_in", liquidTagSignInMarkup>
|
|
270
|
-
liquidTagSignInMarkup = tagArguments space*
|
|
270
|
+
liquidTagSignInMarkup = tagArguments (space* ",")? space*
|
|
271
271
|
|
|
272
272
|
liquidTagRedirectTo = liquidTagRule<"redirect_to", liquidTagRedirectToMarkup>
|
|
273
273
|
liquidTagRedirectToMarkup = liquidExpression<delimTag> renderArguments
|
|
@@ -313,7 +313,12 @@ Liquid <: Helpers {
|
|
|
313
313
|
) endOfIdentifier
|
|
314
314
|
|
|
315
315
|
liquidTagOpenForm = liquidTagOpenRule<"form", liquidTagOpenFormMarkup>
|
|
316
|
-
|
|
316
|
+
// Matches the platformOS runtime (FormForTag): an optional positional model name first
|
|
317
|
+
// ({% form form, method: 'delete' %}), then key: value attributes. The runtime scans
|
|
318
|
+
// ${"`"}[\w-]+: value${"`"} pairs out of the markup, so keys may contain hyphens (html-class:,
|
|
319
|
+
// html-data-user-id:), commas between attributes are optional, and bare {% form %} is valid.
|
|
320
|
+
liquidTagOpenFormMarkup =
|
|
321
|
+
orderedListOf<positionalArgument<delimTag>, namedArgument<delimTag>, argumentSeparatorOptionalComma> (space* ",")? space*
|
|
317
322
|
|
|
318
323
|
liquidTagOpenFor = liquidTagOpenRule<"for", liquidTagOpenForMarkup>
|
|
319
324
|
|
|
@@ -611,18 +616,27 @@ LiquidStatement <: Liquid {
|
|
|
611
616
|
liquidJsonHashLiteral<delim> := "{" (space | newline)* listOf<liquidJsonKeyValue<delim>, liquidJsonSep> (space | newline)* "}"
|
|
612
617
|
liquidJsonArrayLiteral<delim> := "[" (space | newline)* listOf<liquidJsonValue<delim>, liquidJsonSep> (space | newline)* "]"
|
|
613
618
|
|
|
614
|
-
//
|
|
615
|
-
//
|
|
616
|
-
//
|
|
617
|
-
//
|
|
618
|
-
//
|
|
619
|
+
// Inside {% liquid %} blocks, a tag's key:value argument list may span multiple lines.
|
|
620
|
+
// Every argument-list tag whose separator is argumentSeparatorOptionalComma — function,
|
|
621
|
+
// graphql, background, render, include, log, context, sign_in, transaction, cache, etc. —
|
|
622
|
+
// inherits this automatically; the base Liquid grammar keeps these horizontal-only outside
|
|
623
|
+
// {% liquid %}, so the standalone tag/block forms are unaffected (zero regression surface).
|
|
619
624
|
//
|
|
620
|
-
//
|
|
621
|
-
//
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
625
|
+
// A newline is only crossed AFTER a comma AND only when the next non-blank token is a
|
|
626
|
+
// named argument (${"`"}name:${"`"}). This mirrors the Ruby runtime's continuation guard
|
|
627
|
+
// (continuation_line? matches /\A[\w-]+\s*:/): a trailing comma followed by a new
|
|
628
|
+
// directive (another tag, an assign, an echo, a bare/positional value such as
|
|
629
|
+
// ${"`"}log "second"${"`"}, …) does NOT look like ${"`"}name:${"`"}, so the newline is not consumed, the list
|
|
630
|
+
// ends, and the comma is treated as a stylistic trailing comma — the next line stays a
|
|
631
|
+
// separate statement. This guard is essential for positional-accepting lists like log's,
|
|
632
|
+
// where a following directive would otherwise be swallowed as a positional argument.
|
|
633
|
+
//
|
|
634
|
+
// Both alternatives must have the same arity (3: space, comma, group) for Ohm's uniform-arity
|
|
635
|
+
// requirement and consistent visitor child indexing. The positive lookahead is written as
|
|
636
|
+
// ~(~(...)) so it contributes arity 0, keeping the first alternative's group at arity 3.
|
|
637
|
+
argumentSeparatorOptionalComma :=
|
|
638
|
+
space* "," ((space | newline)* ~(~(variableSegment space* ":")))
|
|
639
|
+
| space* ","? space*
|
|
626
640
|
}
|
|
627
641
|
|
|
628
642
|
LiquidDoc <: Helpers {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformos/liquid-html-parser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "Liquid HTML parser for platformOS",
|
|
5
5
|
"author": "platformOS",
|
|
6
6
|
"homepage": "https://github.com/Platform-OS/platformos-tools/tree/master/packages/liquid-html-parser#readme",
|