@platformos/liquid-html-parser 0.0.10 → 0.0.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/dist/grammar.js CHANGED
@@ -31,5 +31,5 @@ exports.RAW_TAGS = (() => {
31
31
  })();
32
32
  // see ../../grammar/liquid-html.ohm for full list
33
33
  exports.VOID_ELEMENTS = exports.strictGrammars.LiquidHTML.rules.voidElementName.body.factors[0].terms.map((x) => x.args[0].obj);
34
- exports.TAGS_WITHOUT_MARKUP = ['else', 'break', 'continue', 'comment', 'raw', 'doc'];
34
+ exports.TAGS_WITHOUT_MARKUP = ['else', 'break', 'continue', 'comment', 'raw', 'doc', 'try'];
35
35
  //# sourceMappingURL=grammar.js.map
@@ -34,6 +34,7 @@ import { Comparators, NamedTags } from './types';
34
34
  export declare enum ConcreteNodeTypes {
35
35
  HtmlDoctype = "HtmlDoctype",
36
36
  HtmlComment = "HtmlComment",
37
+ HtmlProcessingInstruction = "HtmlProcessingInstruction",
37
38
  HtmlRawTag = "HtmlRawTag",
38
39
  HtmlVoidElement = "HtmlVoidElement",
39
40
  HtmlSelfClosingElement = "HtmlSelfClosingElement",
@@ -144,6 +145,9 @@ export interface ConcreteHtmlDoctype extends ConcreteBasicNode<ConcreteNodeTypes
144
145
  export interface ConcreteHtmlComment extends ConcreteBasicNode<ConcreteNodeTypes.HtmlComment> {
145
146
  body: string;
146
147
  }
148
+ export interface ConcreteHtmlProcessingInstruction extends ConcreteBasicNode<ConcreteNodeTypes.HtmlProcessingInstruction> {
149
+ body: string;
150
+ }
147
151
  export interface ConcreteHtmlRawTag extends ConcreteHtmlNodeBase<ConcreteNodeTypes.HtmlRawTag> {
148
152
  name: string;
149
153
  body: string;
@@ -297,7 +301,7 @@ export interface ConcreteLiquidTagGraphQL extends ConcreteLiquidTagNode<NamedTag
297
301
  }
298
302
  export interface ConcreteLiquidTagBackground extends ConcreteLiquidTagNode<NamedTags.background, ConcreteLiquidTagBackgroundMarkup> {
299
303
  }
300
- export interface ConcreteLiquidTagCatch extends ConcreteLiquidTagNode<NamedTags.catch, ConcreteLiquidVariableLookup> {
304
+ export interface ConcreteLiquidTagCatch extends ConcreteLiquidTagNode<NamedTags.catch, ConcreteLiquidVariableLookup | null> {
301
305
  }
302
306
  export interface ConcreteLiquidTagContext extends ConcreteLiquidTagNode<NamedTags.context, ConcreteLiquidNamedArgument[]> {
303
307
  }
@@ -313,9 +317,9 @@ export interface ConcreteLiquidTagRedirectTo extends ConcreteLiquidTagNode<Named
313
317
  }
314
318
  export interface ConcreteLiquidTagResponseHeaders extends ConcreteLiquidTagNode<NamedTags.response_headers, ConcreteLiquidExpression> {
315
319
  }
316
- export interface ConcreteLiquidTagResponseStatus extends ConcreteLiquidTagNode<NamedTags.response_status, ConcreteNumberLiteral> {
320
+ export interface ConcreteLiquidTagResponseStatus extends ConcreteLiquidTagNode<NamedTags.response_status, ConcreteNumberLiteral | ConcreteLiquidVariableLookup> {
317
321
  }
318
- export interface ConcreteLiquidTagReturn extends ConcreteLiquidTagNode<NamedTags.return, ConcreteLiquidVariable> {
322
+ export interface ConcreteLiquidTagReturn extends ConcreteLiquidTagNode<NamedTags.return, ConcreteLiquidVariable | null> {
319
323
  }
320
324
  export interface ConcreteLiquidTagRollback extends ConcreteLiquidTagNode<NamedTags.rollback, string> {
321
325
  }
@@ -349,18 +353,21 @@ export interface ConcreteLiquidTagRenderMarkup extends ConcreteBasicNode<Concret
349
353
  renderArguments: ConcreteLiquidNamedArgument[];
350
354
  }
351
355
  export interface ConcreteLiquidTagFunctionMarkup extends ConcreteBasicNode<ConcreteNodeTypes.FunctionMarkup> {
352
- name: string;
356
+ name: ConcreteLiquidVariableLookup;
353
357
  partial: ConcreteStringLiteral | ConcreteLiquidVariableLookup;
354
358
  functionArguments: ConcreteLiquidNamedArgument[];
359
+ filters: ConcreteLiquidFilter[];
355
360
  }
356
361
  export interface ConcreteLiquidTagGraphQLMarkup extends ConcreteBasicNode<ConcreteNodeTypes.GraphQLMarkup> {
357
362
  name: string;
358
363
  graphql: ConcreteStringLiteral | ConcreteLiquidVariableLookup;
359
364
  functionArguments: ConcreteLiquidNamedArgument[];
365
+ filters: ConcreteLiquidFilter[];
360
366
  }
361
367
  export interface ConcreteLiquidTagGraphQLInlineMarkup extends ConcreteBasicNode<ConcreteNodeTypes.GraphQLInlineMarkup> {
362
368
  name: string;
363
369
  args: ConcreteLiquidNamedArgument[];
370
+ filters: ConcreteLiquidFilter[];
364
371
  }
365
372
  export interface ConcreteLiquidTagBackgroundMarkup extends ConcreteBasicNode<ConcreteNodeTypes.BackgroundMarkup> {
366
373
  jobId: string;
@@ -368,7 +375,6 @@ export interface ConcreteLiquidTagBackgroundMarkup extends ConcreteBasicNode<Con
368
375
  args: ConcreteLiquidNamedArgument[];
369
376
  }
370
377
  export interface ConcreteLiquidTagBackgroundInlineMarkup extends ConcreteBasicNode<ConcreteNodeTypes.BackgroundInlineMarkup> {
371
- jobId: ConcreteLiquidVariableLookup;
372
378
  args: ConcreteLiquidNamedArgument[];
373
379
  }
374
380
  export interface ConcreteLiquidTagCacheMarkup extends ConcreteBasicNode<ConcreteNodeTypes.CacheMarkup> {
@@ -377,15 +383,15 @@ export interface ConcreteLiquidTagCacheMarkup extends ConcreteBasicNode<Concrete
377
383
  }
378
384
  export interface ConcreteLiquidTagLogMarkup extends ConcreteBasicNode<ConcreteNodeTypes.LogMarkup> {
379
385
  value: ConcreteLiquidExpression;
380
- args: ConcreteLiquidNamedArgument[];
386
+ args: ConcreteLiquidArgument[];
381
387
  }
382
388
  export interface ConcreteLiquidTagSessionMarkup extends ConcreteBasicNode<ConcreteNodeTypes.SessionMarkup> {
383
389
  name: string;
384
- value: ConcreteLiquidExpression;
390
+ value: ConcreteLiquidVariable;
385
391
  }
386
392
  export interface ConcreteLiquidTagExportMarkup extends ConcreteBasicNode<ConcreteNodeTypes.ExportMarkup> {
387
393
  variables: ConcreteLiquidVariableLookup[];
388
- namespace: ConcreteLiquidNamedArgument;
394
+ namespace: ConcreteLiquidNamedArgument | null;
389
395
  }
390
396
  export interface ConcreteLiquidTagRedirectToMarkup extends ConcreteBasicNode<ConcreteNodeTypes.RedirectToMarkup> {
391
397
  url: ConcreteLiquidExpression;
@@ -421,7 +427,7 @@ export interface ConcreteLiquidFilter extends ConcreteBasicNode<ConcreteNodeType
421
427
  export type ConcreteLiquidArgument = ConcreteLiquidExpression | ConcreteLiquidNamedArgument;
422
428
  export interface ConcreteLiquidNamedArgument extends ConcreteBasicNode<ConcreteNodeTypes.NamedArgument> {
423
429
  name: string;
424
- value: ConcreteLiquidExpression | ConcreteLiquidVariable;
430
+ value: ConcreteLiquidExpression | ConcreteLiquidVariable | ConcreteLiquidNamedArgument;
425
431
  }
426
432
  export type ConcreteLiquidExpression = ConcreteStringLiteral | ConcreteNumberLiteral | ConcreteLiquidLiteral | ConcreteLiquidRange | ConcreteLiquidVariableLookup | ConcreteJsonHashLiteral | ConcreteJsonArrayLiteral;
427
433
  export type ConcreteComplexLiquidExpression = ConcreteLiquidBooleanExpression | ConcreteLiquidExpression;
@@ -458,7 +464,7 @@ export interface ConcreteJsonArrayLiteral extends ConcreteBasicNode<ConcreteNode
458
464
  elements: ConcreteJsonValue[];
459
465
  }
460
466
  export type ConcreteJsonValue = ConcreteJsonHashLiteral | ConcreteJsonArrayLiteral | ConcreteLiquidVariable | ConcreteLiquidExpression;
461
- export type ConcreteHtmlNode = ConcreteHtmlDoctype | ConcreteHtmlComment | ConcreteHtmlRawTag | ConcreteHtmlVoidElement | ConcreteHtmlSelfClosingElement | ConcreteHtmlTagOpen | ConcreteHtmlTagClose;
467
+ export type ConcreteHtmlNode = ConcreteHtmlDoctype | ConcreteHtmlComment | ConcreteHtmlProcessingInstruction | ConcreteHtmlRawTag | ConcreteHtmlVoidElement | ConcreteHtmlSelfClosingElement | ConcreteHtmlTagOpen | ConcreteHtmlTagClose;
462
468
  export interface ConcreteTextNode extends ConcreteBasicNode<ConcreteNodeTypes.TextNode> {
463
469
  value: string;
464
470
  }
@@ -42,6 +42,7 @@ var ConcreteNodeTypes;
42
42
  (function (ConcreteNodeTypes) {
43
43
  ConcreteNodeTypes["HtmlDoctype"] = "HtmlDoctype";
44
44
  ConcreteNodeTypes["HtmlComment"] = "HtmlComment";
45
+ ConcreteNodeTypes["HtmlProcessingInstruction"] = "HtmlProcessingInstruction";
45
46
  ConcreteNodeTypes["HtmlRawTag"] = "HtmlRawTag";
46
47
  ConcreteNodeTypes["HtmlVoidElement"] = "HtmlVoidElement";
47
48
  ConcreteNodeTypes["HtmlSelfClosingElement"] = "HtmlSelfClosingElement";
@@ -474,11 +475,22 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
474
475
  locEnd,
475
476
  source,
476
477
  },
478
+ liquidTagIncludeMarkup: {
479
+ type: ConcreteNodeTypes.RenderMarkup,
480
+ partial: 0,
481
+ variable: 1,
482
+ alias: 2,
483
+ renderArguments: 3,
484
+ locStart,
485
+ locEnd,
486
+ source,
487
+ },
477
488
  liquidTagFunctionMarkup: {
478
489
  type: ConcreteNodeTypes.FunctionMarkup,
479
490
  name: 0,
480
491
  partial: 4,
481
492
  functionArguments: 5,
493
+ filters: 6,
482
494
  locStart,
483
495
  locEnd,
484
496
  source,
@@ -488,6 +500,7 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
488
500
  name: 0,
489
501
  graphql: 4,
490
502
  functionArguments: 5,
503
+ filters: 6,
491
504
  locStart,
492
505
  locEnd,
493
506
  source,
@@ -496,6 +509,7 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
496
509
  type: ConcreteNodeTypes.GraphQLInlineMarkup,
497
510
  name: 0,
498
511
  args: 1,
512
+ filters: 2,
499
513
  locStart,
500
514
  locEnd,
501
515
  source,
@@ -514,8 +528,7 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
514
528
  liquidTagOpenBackground: 0,
515
529
  liquidTagBackgroundInlineMarkup: {
516
530
  type: ConcreteNodeTypes.BackgroundInlineMarkup,
517
- jobId: 0,
518
- args: 2,
531
+ args: 1,
519
532
  locStart,
520
533
  locEnd,
521
534
  source,
@@ -534,6 +547,7 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
534
547
  liquidTagOpenTransactionMarkup: 0,
535
548
  liquidTagOpenTry: 0,
536
549
  liquidTagCatch: 0,
550
+ liquidTagCatchMarkup: 0,
537
551
  liquidTagLog: 0,
538
552
  liquidTagLogMarkup: {
539
553
  type: ConcreteNodeTypes.LogMarkup,
@@ -543,8 +557,22 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
543
557
  locEnd,
544
558
  source,
545
559
  },
560
+ liquidTagLogArguments: 1,
561
+ logArguments: 0,
562
+ logArgument: 0,
546
563
  liquidTagPrint: 0,
547
564
  liquidTagReturn: 0,
565
+ liquidTagReturnMarkup: 0,
566
+ liquidReturnVariable: {
567
+ type: ConcreteNodeTypes.LiquidVariable,
568
+ expression: 0,
569
+ filters: 1,
570
+ rawSource: (tokens) => source.slice(locStart(tokens), tokens[tokens.length - 2].source.endIdx).trimEnd(),
571
+ locStart,
572
+ locEnd: locEndSecondToLast,
573
+ source,
574
+ },
575
+ liquidReturnExpression: 0,
548
576
  liquidTagYield: 0,
549
577
  liquidTagYieldMarkup: 0,
550
578
  liquidTagSession: 0,
@@ -560,11 +588,12 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
560
588
  liquidTagExportMarkup: {
561
589
  type: ConcreteNodeTypes.ExportMarkup,
562
590
  variables: 0,
563
- namespace: 2,
591
+ namespace: 1,
564
592
  locStart,
565
593
  locEnd,
566
594
  source,
567
595
  },
596
+ liquidTagExportNamespace: 1,
568
597
  exportVariable: 0,
569
598
  liquidTagContext: 0,
570
599
  liquidTagContextMarkup: 0,
@@ -706,6 +735,15 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
706
735
  locEnd,
707
736
  source,
708
737
  },
738
+ namedArgumentValue: 0,
739
+ hashPairValue: {
740
+ type: ConcreteNodeTypes.NamedArgument,
741
+ name: 0,
742
+ value: 4,
743
+ locStart,
744
+ locEnd,
745
+ source,
746
+ },
709
747
  graphqlNamedArgument: {
710
748
  type: ConcreteNodeTypes.NamedArgument,
711
749
  name: 0,
@@ -717,7 +755,7 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
717
755
  graphqlNamedArgumentValue: {
718
756
  type: ConcreteNodeTypes.LiquidVariable,
719
757
  expression: 0,
720
- filters: 1,
758
+ filters: () => [],
721
759
  rawSource: (tokens) => source.slice(locStart(tokens), locEnd(tokens)),
722
760
  locStart,
723
761
  locEnd,
@@ -958,6 +996,13 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
958
996
  locEnd,
959
997
  source,
960
998
  },
999
+ HtmlProcessingInstruction: {
1000
+ type: ConcreteNodeTypes.HtmlProcessingInstruction,
1001
+ body: markup(1),
1002
+ locStart,
1003
+ locEnd,
1004
+ source,
1005
+ },
961
1006
  HtmlRawTagImpl: {
962
1007
  type: ConcreteNodeTypes.HtmlRawTag,
963
1008
  name: (tokens) => tokens[0].children[1].sourceString,
@@ -281,8 +281,8 @@ export interface RenderMarkup extends ASTNode<NodeTypes.RenderMarkup> {
281
281
  }
282
282
  /** {% function res = 'partial', [...namedArguments] %} */
283
283
  export interface FunctionMarkup extends ASTNode<NodeTypes.FunctionMarkup> {
284
- /** {% function res = 'partial' %} */
285
- name: string;
284
+ /** {% function res = 'partial' %} or {% function hash['key'] = 'partial' %} */
285
+ name: LiquidVariableLookup;
286
286
  partial: LiquidString | LiquidVariableLookup;
287
287
  /**
288
288
  * WARNING: `args` could contain LiquidVariableLookup when we are in a completion context
@@ -292,6 +292,8 @@ export interface FunctionMarkup extends ASTNode<NodeTypes.FunctionMarkup> {
292
292
  * @example {% function res = 'partial', arg1: value1, arg2: value2 %}
293
293
  */
294
294
  args: LiquidNamedArgument[];
295
+ /** Filters applied to the result variable, e.g. {% function res = 'path' | dig: 'key' %} */
296
+ filters: LiquidFilter[];
295
297
  }
296
298
  /** {% graphql res = 'path/to/graphql/file', [...namedArguments] %} (file-based) */
297
299
  export interface GraphQLMarkup extends ASTNode<NodeTypes.GraphQLMarkup> {
@@ -306,6 +308,8 @@ export interface GraphQLMarkup extends ASTNode<NodeTypes.GraphQLMarkup> {
306
308
  * @example {% graphql res = 'file', arg1: value1, arg2: value2 %}
307
309
  */
308
310
  args: LiquidNamedArgument[];
311
+ /** Filters applied to the result variable, e.g. {% graphql res = 'path' | dig: 'key' %} */
312
+ filters: LiquidFilter[];
309
313
  }
310
314
  /** {% graphql res, [...namedArguments] %}...{% endgraphql %} (inline) */
311
315
  export interface GraphQLInlineMarkup extends ASTNode<NodeTypes.GraphQLInlineMarkup> {
@@ -319,6 +323,8 @@ export interface GraphQLInlineMarkup extends ASTNode<NodeTypes.GraphQLInlineMark
319
323
  * @example {% graphql res, arg1: value1, arg2: value2 %}
320
324
  */
321
325
  args: LiquidNamedArgument[];
326
+ /** Filters applied to the result variable, e.g. {% graphql res | dig: 'key' %} */
327
+ filters: LiquidFilter[];
322
328
  }
323
329
  export interface LiquidTagBackground extends LiquidTagNode<NamedTags.background, BackgroundMarkup | BackgroundInlineMarkup> {
324
330
  }
@@ -340,9 +346,9 @@ export interface LiquidTagRedirectTo extends LiquidTagNode<NamedTags.redirect_to
340
346
  }
341
347
  export interface LiquidTagResponseHeaders extends LiquidTagNode<NamedTags.response_headers, LiquidExpression> {
342
348
  }
343
- export interface LiquidTagResponseStatus extends LiquidTagNode<NamedTags.response_status, LiquidNumber> {
349
+ export interface LiquidTagResponseStatus extends LiquidTagNode<NamedTags.response_status, LiquidNumber | LiquidVariableLookup> {
344
350
  }
345
- export interface LiquidTagReturn extends LiquidTagNode<NamedTags.return, LiquidVariable> {
351
+ export interface LiquidTagReturn extends LiquidTagNode<NamedTags.return, LiquidVariable | null> {
346
352
  }
347
353
  export interface LiquidTagRollback extends LiquidTagNode<NamedTags.rollback, string> {
348
354
  }
@@ -360,7 +366,7 @@ export interface LiquidTagTry extends LiquidTagNode<NamedTags.try, string> {
360
366
  }
361
367
  export interface LiquidTagYield extends LiquidTagNode<NamedTags.yield, LiquidExpression> {
362
368
  }
363
- export interface LiquidBranchCatch extends LiquidBranchNode<NamedTags.catch, LiquidVariableLookup> {
369
+ export interface LiquidBranchCatch extends LiquidBranchNode<NamedTags.catch, LiquidVariableLookup | null> {
364
370
  }
365
371
  /** {% background job_id = 'partial', [...namedArguments] %} (file-based) */
366
372
  export interface BackgroundMarkup extends ASTNode<NodeTypes.BackgroundMarkup> {
@@ -368,9 +374,8 @@ export interface BackgroundMarkup extends ASTNode<NodeTypes.BackgroundMarkup> {
368
374
  partial: LiquidString | LiquidVariableLookup;
369
375
  args: LiquidNamedArgument[];
370
376
  }
371
- /** {% background jobId[, ...namedArguments] %}...{% endbackground %} (inline) */
377
+ /** {% background ...namedArguments %}...{% endbackground %} (inline) */
372
378
  export interface BackgroundInlineMarkup extends ASTNode<NodeTypes.BackgroundInlineMarkup> {
373
- jobId: LiquidVariableLookup;
374
379
  args: LiquidNamedArgument[];
375
380
  }
376
381
  /** {% cache 'key', [...namedArguments] %}...{% endcache %} */
@@ -378,20 +383,20 @@ export interface CacheMarkup extends ASTNode<NodeTypes.CacheMarkup> {
378
383
  key: LiquidExpression;
379
384
  args: LiquidNamedArgument[];
380
385
  }
381
- /** {% log value, [...namedArguments] %} */
386
+ /** {% log value, [...arguments] %} */
382
387
  export interface LogMarkup extends ASTNode<NodeTypes.LogMarkup> {
383
388
  value: LiquidExpression;
384
- args: LiquidNamedArgument[];
389
+ args: LiquidArgument[];
385
390
  }
386
- /** {% session name = value %} */
391
+ /** {% session name = value [| filter] %} */
387
392
  export interface SessionMarkup extends ASTNode<NodeTypes.SessionMarkup> {
388
393
  name: string;
389
- value: LiquidExpression;
394
+ value: LiquidVariable;
390
395
  }
391
- /** {% export a, b, namespace: 'ns' %} */
396
+ /** {% export a, b[, namespace: 'ns'] %} */
392
397
  export interface ExportMarkup extends ASTNode<NodeTypes.ExportMarkup> {
393
398
  variables: LiquidVariableLookup[];
394
- namespace: LiquidNamedArgument;
399
+ namespace: LiquidNamedArgument | null;
395
400
  }
396
401
  /** {% redirect_to '/path', [...namedArguments] %} */
397
402
  export interface RedirectToMarkup extends ASTNode<NodeTypes.RedirectToMarkup> {
@@ -512,8 +517,9 @@ export interface LiquidNamedArgument extends ASTNode<NodeTypes.NamedArgument> {
512
517
  /**
513
518
  * For regular tags (render, function, for, etc.): a plain LiquidExpression (no filters).
514
519
  * For graphql tags: a LiquidVariable which may include filters (e.g. `name: val | fetch: "key"`).
520
+ * For hash pair values (e.g. `key: 'val'`): a nested LiquidNamedArgument.
515
521
  */
516
- value: LiquidExpression | LiquidVariable;
522
+ value: LiquidExpression | LiquidVariable | LiquidNamedArgument;
517
523
  }
518
524
  export interface LiquidBooleanExpression extends ASTNode<NodeTypes.BooleanExpression> {
519
525
  condition: LiquidConditionalExpression;
@@ -570,7 +576,7 @@ export interface JsonArrayLiteral extends ASTNode<NodeTypes.JsonArrayLiteral> {
570
576
  elements: (LiquidExpression | LiquidVariable)[];
571
577
  }
572
578
  /** The union type of all HTML nodes */
573
- export type HtmlNode = HtmlComment | HtmlElement | HtmlDanglingMarkerClose | HtmlVoidElement | HtmlSelfClosingElement | HtmlRawNode;
579
+ export type HtmlNode = HtmlComment | HtmlProcessingInstruction | HtmlElement | HtmlDanglingMarkerClose | HtmlVoidElement | HtmlSelfClosingElement | HtmlRawNode;
574
580
  /** The basic HTML node with an opening and closing tags. */
575
581
  export interface HtmlElement extends HtmlNodeBase<NodeTypes.HtmlElement> {
576
582
  /**
@@ -666,6 +672,10 @@ export interface HtmlDoctype extends ASTNode<NodeTypes.HtmlDoctype> {
666
672
  export interface HtmlComment extends ASTNode<NodeTypes.HtmlComment> {
667
673
  body: string;
668
674
  }
675
+ /** Represents XML declarations and processing instructions: `<?xml ... ?>`, `<?...?>` */
676
+ export interface HtmlProcessingInstruction extends ASTNode<NodeTypes.HtmlProcessingInstruction> {
677
+ body: string;
678
+ }
669
679
  export interface HtmlNodeBase<T> extends ASTNode<T> {
670
680
  /** the HTML and Liquid attributes of the HTML tag */
671
681
  attributes: AttributeNode[];
@@ -381,6 +381,15 @@ function buildAst(cst, options) {
381
381
  });
382
382
  break;
383
383
  }
384
+ case stage_1_cst_1.ConcreteNodeTypes.HtmlProcessingInstruction: {
385
+ builder.push({
386
+ type: types_1.NodeTypes.HtmlProcessingInstruction,
387
+ body: node.body,
388
+ position: position(node),
389
+ source: node.source,
390
+ });
391
+ break;
392
+ }
384
393
  case stage_1_cst_1.ConcreteNodeTypes.HtmlRawTag: {
385
394
  builder.push({
386
395
  type: types_1.NodeTypes.HtmlRawNode,
@@ -768,7 +777,7 @@ function toNamedLiquidTag(node, options) {
768
777
  return {
769
778
  ...liquidBranchBaseAttributes(node),
770
779
  name: node.name,
771
- markup: toExpression(node.markup),
780
+ markup: node.markup ? toExpression(node.markup) : null,
772
781
  };
773
782
  }
774
783
  case types_1.NamedTags.log: {
@@ -778,14 +787,20 @@ function toNamedLiquidTag(node, options) {
778
787
  markup: toLogMarkup(node.markup),
779
788
  };
780
789
  }
781
- case types_1.NamedTags.print:
782
- case types_1.NamedTags.return: {
790
+ case types_1.NamedTags.print: {
783
791
  return {
784
792
  ...liquidTagBaseAttributes(node),
785
793
  name: node.name,
786
794
  markup: toLiquidVariable(node.markup),
787
795
  };
788
796
  }
797
+ case types_1.NamedTags.return: {
798
+ return {
799
+ ...liquidTagBaseAttributes(node),
800
+ name: node.name,
801
+ markup: node.markup ? toLiquidVariable(node.markup) : null,
802
+ };
803
+ }
789
804
  case types_1.NamedTags.yield: {
790
805
  return {
791
806
  ...liquidTagBaseAttributes(node),
@@ -1044,7 +1059,7 @@ function toRenderMarkup(node) {
1044
1059
  }
1045
1060
  function toFunctionMarkup(node) {
1046
1061
  return {
1047
- name: node.name,
1062
+ name: toExpression(node.name),
1048
1063
  type: types_1.NodeTypes.FunctionMarkup,
1049
1064
  partial: toExpression(node.partial),
1050
1065
  /**
@@ -1056,6 +1071,7 @@ function toFunctionMarkup(node) {
1056
1071
  * but this is the compromise we're making to get completions to work.
1057
1072
  */
1058
1073
  args: node.functionArguments.map(toLiquidArgument),
1074
+ filters: node.filters.map(toFilter),
1059
1075
  position: position(node),
1060
1076
  source: node.source,
1061
1077
  };
@@ -1074,6 +1090,7 @@ function toGraphQLMarkup(node) {
1074
1090
  * but this is the compromise we're making to get completions to work.
1075
1091
  */
1076
1092
  args: node.functionArguments.map(toLiquidArgument),
1093
+ filters: node.filters.map(toFilter),
1077
1094
  position: position(node),
1078
1095
  source: node.source,
1079
1096
  };
@@ -1091,6 +1108,7 @@ function toGraphQLInlineMarkup(node) {
1091
1108
  * but this is the compromise we're making to get completions to work.
1092
1109
  */
1093
1110
  args: node.args.map(toLiquidArgument),
1111
+ filters: node.filters.map(toFilter),
1094
1112
  position: position(node),
1095
1113
  source: node.source,
1096
1114
  };
@@ -1109,7 +1127,6 @@ function toBackgroundMarkup(node) {
1109
1127
  function toBackgroundInlineMarkup(node) {
1110
1128
  return {
1111
1129
  type: types_1.NodeTypes.BackgroundInlineMarkup,
1112
- jobId: toExpression(node.jobId),
1113
1130
  args: node.args.map(toLiquidArgument),
1114
1131
  position: position(node),
1115
1132
  source: node.source,
@@ -1137,7 +1154,7 @@ function toSessionMarkup(node) {
1137
1154
  return {
1138
1155
  type: types_1.NodeTypes.SessionMarkup,
1139
1156
  name: node.name,
1140
- value: toExpression(node.value),
1157
+ value: toLiquidVariable(node.value),
1141
1158
  position: position(node),
1142
1159
  source: node.source,
1143
1160
  };
@@ -1146,7 +1163,7 @@ function toExportMarkup(node) {
1146
1163
  return {
1147
1164
  type: types_1.NodeTypes.ExportMarkup,
1148
1165
  variables: node.variables.map((v) => toExpression(v)),
1149
- namespace: toNamedArgument(node.namespace),
1166
+ namespace: node.namespace ? toNamedArgument(node.namespace) : null,
1150
1167
  position: position(node),
1151
1168
  source: node.source,
1152
1169
  };
@@ -1373,12 +1390,20 @@ function toLiquidArgument(node) {
1373
1390
  }
1374
1391
  }
1375
1392
  function toNamedArgument(node) {
1393
+ let value;
1394
+ if (node.value.type === stage_1_cst_1.ConcreteNodeTypes.LiquidVariable) {
1395
+ value = toLiquidVariable(node.value);
1396
+ }
1397
+ else if (node.value.type === stage_1_cst_1.ConcreteNodeTypes.NamedArgument) {
1398
+ value = toNamedArgument(node.value);
1399
+ }
1400
+ else {
1401
+ value = toExpression(node.value);
1402
+ }
1376
1403
  return {
1377
1404
  type: types_1.NodeTypes.NamedArgument,
1378
1405
  name: node.name,
1379
- value: node.value.type === stage_1_cst_1.ConcreteNodeTypes.LiquidVariable
1380
- ? toLiquidVariable(node.value)
1381
- : toExpression(node.value),
1406
+ value,
1382
1407
  position: position(node),
1383
1408
  source: node.source,
1384
1409
  };
package/dist/types.d.ts CHANGED
@@ -14,6 +14,7 @@ export declare enum NodeTypes {
14
14
  HtmlVoidElement = "HtmlVoidElement",
15
15
  HtmlDoctype = "HtmlDoctype",
16
16
  HtmlComment = "HtmlComment",
17
+ HtmlProcessingInstruction = "HtmlProcessingInstruction",
17
18
  HtmlElement = "HtmlElement",
18
19
  HtmlDanglingMarkerClose = "HtmlDanglingMarkerClose",
19
20
  HtmlRawNode = "HtmlRawNode",
package/dist/types.js CHANGED
@@ -12,6 +12,7 @@ var NodeTypes;
12
12
  NodeTypes["HtmlVoidElement"] = "HtmlVoidElement";
13
13
  NodeTypes["HtmlDoctype"] = "HtmlDoctype";
14
14
  NodeTypes["HtmlComment"] = "HtmlComment";
15
+ NodeTypes["HtmlProcessingInstruction"] = "HtmlProcessingInstruction";
15
16
  NodeTypes["HtmlElement"] = "HtmlElement";
16
17
  NodeTypes["HtmlDanglingMarkerClose"] = "HtmlDanglingMarkerClose";
17
18
  NodeTypes["HtmlRawNode"] = "HtmlRawNode";
@@ -106,7 +106,7 @@ Liquid <: Helpers {
106
106
 
107
107
  liquidTagOpenGraphQL = liquidTagOpenRule<"graphql", liquidTagGraphQLInlineMarkup>
108
108
  // Use negative lookahead to exclude file-based syntax (with "=")
109
- liquidTagGraphQLInlineMarkup = variableSegment ~(space* "=") graphqlRenderArguments
109
+ liquidTagGraphQLInlineMarkup = variableSegment ~(space* "=") graphqlRenderArguments liquidFilter<delimTag>* space*
110
110
 
111
111
  liquidTagOpen =
112
112
  | liquidTagOpenStrict
@@ -201,25 +201,28 @@ Liquid <: Helpers {
201
201
  liquidTagContentForMarkup = contentForType space*
202
202
  contentForType = liquidString<delimTag>
203
203
 
204
- liquidTagInclude = liquidTagRule<"include", liquidTagRenderMarkup>
204
+ liquidTagInclude = liquidTagRule<"include", liquidTagIncludeMarkup>
205
+ liquidTagIncludeMarkup =
206
+ partialExpression renderVariableExpression? renderAliasExpression? renderArguments
207
+
205
208
  liquidTagRender = liquidTagRule<"render", liquidTagRenderMarkup>
206
209
  liquidTagRenderMarkup =
207
- partialExpression renderVariableExpression? renderAliasExpression? renderArguments
210
+ liquidString<delimTag> renderVariableExpression? renderAliasExpression? renderArguments
208
211
 
209
212
  liquidTagFunction = liquidTagRule<"function", liquidTagFunctionMarkup>
210
- liquidTagFunctionMarkup = variableSegment space* "=" space* partialExpression renderArguments
213
+ liquidTagFunctionMarkup = liquidVariableLookup<delimTag> space* "=" space* partialExpression renderArguments liquidFilter<delimTag>* space*
211
214
 
212
215
  liquidTagGraphQL = liquidTagRule<"graphql", liquidTagGraphQLMarkup>
213
- liquidTagGraphQLMarkup = variableSegment space* "=" space* partialExpression graphqlRenderArguments
216
+ liquidTagGraphQLMarkup = variableSegment space* "=" space* partialExpression graphqlRenderArguments liquidFilter<delimTag>* space*
214
217
 
215
218
  // platformos simple tags
216
219
  liquidTagBackground = liquidTagRule<"background", liquidTagBackgroundMarkup>
217
220
  liquidTagBackgroundMarkup = variableSegment space* "=" space* partialExpression renderArguments
218
221
 
219
222
  liquidTagOpenBackground = liquidTagOpenRule<"background", liquidTagBackgroundInlineMarkup>
223
+ // Block form: only named arguments, no result variable (matches Ruby inline syntax)
220
224
  // Use negative lookahead to exclude file-based syntax (with "=")
221
- // jobId is required before any arguments
222
- liquidTagBackgroundInlineMarkup = ~(variableSegment space* "=") variableSegmentAsLookup argumentSeparatorOptionalComma tagArguments space*
225
+ liquidTagBackgroundInlineMarkup = ~(variableSegment space* "=") argumentSeparatorOptionalComma tagArguments space*
223
226
 
224
227
  liquidTagOpenCache = liquidTagOpenRule<"cache", liquidTagCacheMarkup>
225
228
  liquidTagCacheMarkup = liquidExpression<delimTag> renderArguments
@@ -231,23 +234,34 @@ Liquid <: Helpers {
231
234
 
232
235
  liquidTagOpenTry = liquidTagOpenRule<"try", empty>
233
236
 
234
- liquidTagCatch = liquidTagRule<"catch", variableSegmentAsLookupMarkup>
237
+ liquidTagCatch = liquidTagRule<"catch", liquidTagCatchMarkup>
238
+ liquidTagCatchMarkup = variableSegmentAsLookup? space*
235
239
 
236
240
  liquidTagLog = liquidTagRule<"log", liquidTagLogMarkup>
237
- liquidTagLogMarkup = liquidExpression<delimTag> renderArguments
241
+ liquidTagLogMarkup = liquidExpression<delimTag> liquidTagLogArguments
242
+ liquidTagLogArguments = (argumentSeparatorOptionalComma logArguments) (space* ",")? space*
243
+ logArguments = listOf<logArgument<delimTag>, argumentSeparatorOptionalComma>
244
+ logArgument<delim> = namedArgument<delim> | positionalArgument<delim>
238
245
 
239
246
  liquidTagPrint = liquidTagRule<"print", liquidTagEchoMarkup>
240
247
 
241
- liquidTagReturn = liquidTagRule<"return", liquidTagEchoMarkup>
248
+ liquidTagReturn = liquidTagRule<"return", liquidTagReturnMarkup>
249
+ liquidTagReturnMarkup = liquidReturnVariable<delimTag>? space*
250
+ liquidReturnVariable<delim> = liquidReturnExpression<delim> liquidFilter<delim>* space* &delim
251
+ liquidReturnExpression<delim> =
252
+ | liquidJsonHashLiteral<delim>
253
+ | liquidJsonArrayLiteral<delim>
254
+ | liquidComplexExpression<delim>
242
255
 
243
256
  liquidTagYield = liquidTagRule<"yield", liquidTagYieldMarkup>
244
257
  liquidTagYieldMarkup = liquidExpression<delimTag> space*
245
258
 
246
259
  liquidTagSession = liquidTagRule<"session", liquidTagSessionMarkup>
247
- liquidTagSessionMarkup = variableSegment space* "=" space* liquidExpression<delimTag> space*
260
+ liquidTagSessionMarkup = variableSegment space* "=" space* liquidVariable<delimTag> space*
248
261
 
249
262
  liquidTagExport = liquidTagRule<"export", liquidTagExportMarkup>
250
- liquidTagExportMarkup = nonemptyListOf<exportVariable, argumentSeparator> argumentSeparatorOptionalComma namedArgument<delimTag> space*
263
+ liquidTagExportMarkup = nonemptyListOf<exportVariable, argumentSeparator> liquidTagExportNamespace? space*
264
+ liquidTagExportNamespace = argumentSeparatorOptionalComma namedArgument<delimTag>
251
265
  // Variable lookup that is NOT followed by ":" (to distinguish from named arguments)
252
266
  exportVariable = variableSegmentAsLookup ~(space* ":")
253
267
 
@@ -269,7 +283,7 @@ Liquid <: Helpers {
269
283
  liquidTagThemeRenderRc = liquidTagRule<"theme_render_rc", liquidTagRenderMarkup>
270
284
 
271
285
  liquidTagResponseStatus = liquidTagRule<"response_status", liquidTagResponseStatusMarkup>
272
- liquidTagResponseStatusMarkup = liquidNumber space*
286
+ liquidTagResponseStatusMarkup = (liquidNumber | liquidVariableLookup<delimTag>) space*
273
287
 
274
288
  liquidTagResponseHeaders = liquidTagRule<"response_headers", liquidTagResponseHeadersMarkup>
275
289
  liquidTagResponseHeadersMarkup = liquidExpression<delimTag> space*
@@ -278,7 +292,7 @@ Liquid <: Helpers {
278
292
 
279
293
  renderArguments = (argumentSeparatorOptionalComma tagArguments) (space* ",")? space*
280
294
  completionModeRenderArguments = (argumentSeparatorOptionalComma tagArguments) (space* ",")? space* (argumentSeparator? liquidVariableLookup<delimTag> space*)?
281
- partialExpression = liquidString<delimTag> | variableSegmentAsLookup
295
+ partialExpression = liquidString<delimTag> | liquidVariableLookup<delimTag>
282
296
  renderVariableExpression = space+ ("for" | "with") space+ liquidExpression<delimTag>
283
297
  renderAliasExpression = space+ "as" space+ variableSegment
284
298
 
@@ -427,7 +441,8 @@ Liquid <: Helpers {
427
441
  | indexLookup<delim>
428
442
  | dotLookup
429
443
  indexLookup<delim> = space* "[" space* liquidExpression<delim> space* "]"
430
- dotLookup = space* "." space* identifier
444
+ dotLookup = space* "." space* dotLookupName
445
+ dotLookupName = (alnum | "_") (~endOfTagName identifierCharacter)* "?"?
431
446
 
432
447
  liquidFilter<delim> = space* "|" space* identifier (space* ":" space* arguments<delim> (space* ",")?)?
433
448
 
@@ -435,11 +450,13 @@ Liquid <: Helpers {
435
450
  argumentSeparator = space* "," space*
436
451
  argumentSeparatorOptionalComma = space* ","? space*
437
452
  positionalArgument<delim> = liquidExpression<delim> ~(space* ":")
438
- namedArgument<delim> = variableSegment space* ":" space* liquidExpression<delim>
453
+ namedArgument<delim> = variableSegment space* ":" space* namedArgumentValue<delim>
454
+ namedArgumentValue<delim> = hashPairValue<delim> | liquidExpression<delim>
455
+ hashPairValue<delim> = variableSegment space* ":" space* liquidExpression<delim>
439
456
  tagArguments = listOf<namedArgument<delimTag>, argumentSeparatorOptionalComma>
440
457
  graphqlArguments = listOf<graphqlNamedArgument, argumentSeparatorOptionalComma>
441
458
  graphqlNamedArgument = variableSegment space* ":" space* graphqlNamedArgumentValue
442
- graphqlNamedArgumentValue = liquidExpression<delimTag> liquidFilter<delimTag>*
459
+ graphqlNamedArgumentValue = liquidExpression<delimTag>
443
460
  graphqlRenderArguments = (argumentSeparatorOptionalComma graphqlArguments) (space* ",")? space*
444
461
  filterArguments<delim> =
445
462
  | complexArguments<delim>
@@ -481,7 +498,10 @@ Liquid <: Helpers {
481
498
  }
482
499
 
483
500
  LiquidStatement <: Liquid {
484
- Node := listOf<LiquidStatement, statementSep> (space | newline)*
501
+ // Trailing ";"? and "#..." comment are consumed by Node and statementSep; the `;?`/`#` in
502
+ // liquidStatementEnd make &delimTag succeed before them so expression rules terminate correctly.
503
+ // tagMarkup uses liquidLineEnd (newline|end only) so inline-comment text is never truncated.
504
+ Node := listOf<LiquidStatement, statementSep> ";"? ("#" (~newline any)*)? (space | newline)*
485
505
 
486
506
  // This is the big brains moment: we redefine space to exclude newlines.
487
507
  //
@@ -547,12 +567,23 @@ LiquidStatement <: Liquid {
547
567
  liquidInlineComment
548
568
  := "#" space? tagMarkup &liquidStatementEnd
549
569
 
550
- tagMarkup := anyExceptStar<liquidStatementEnd>
570
+ // tagMarkup uses liquidLineEnd (newline|end) so that raw # text is never cut off
571
+ // (liquidInlineComment content, base-case tag markup, close-tag markup).
572
+ liquidLineEnd = newline | end
573
+ tagMarkup := anyExceptStar<liquidLineEnd>
551
574
 
552
- // trailing whitespace, newline, + anything else before the next tag
553
- statementSep = space* newline (space | newline)*
575
+ // Override string rules so that '#' inside string content is never mistaken for a
576
+ // delimTag inline-comment marker. In LiquidStatement, delimTag includes `# ...` which
577
+ // would otherwise cause anyExceptStar<delim> to stop inside strings like '##label##'.
578
+ // Strings in liquid blocks end at the matching quote or at a newline (no multi-line strings).
579
+ liquidSingleQuotedString<delim> := "'" anyExceptStar<("'" | newline | end)> "'"
580
+ liquidDoubleQuotedString<delim> := "\"" anyExceptStar<("\"" | newline | end)> "\""
554
581
 
555
- liquidStatementEnd = newline | end
582
+ // trailing whitespace, newline, + optional leading `;` and `# comment` before the next tag
583
+ statementSep = space* ";"? space* ("#" (~newline any)*)? newline (space | newline)*
584
+
585
+ // delimTag is used as &delim lookahead in expression rules; it must succeed before `;` and `#`
586
+ liquidStatementEnd = ";"? space* ("#" (~newline any)*)? (newline | end)
556
587
  delimTag := liquidStatementEnd
557
588
  }
558
589
 
@@ -611,6 +642,7 @@ LiquidHTML <: Liquid {
611
642
  HtmlNode =
612
643
  | HtmlDoctype
613
644
  | HtmlComment
645
+ | HtmlProcessingInstruction
614
646
  | HtmlRawTag
615
647
  | HtmlVoidElement
616
648
  | HtmlSelfClosingElement
@@ -625,6 +657,9 @@ LiquidHTML <: Liquid {
625
657
 
626
658
  HtmlComment = "<!--" #(anyExceptStar<"-->"> "-->")
627
659
 
660
+ // Handles XML declarations (<?xml ...?>) and other processing instructions (<?...?>)
661
+ HtmlProcessingInstruction = "<?" #(anyExceptStar<"?>"> "?>")
662
+
628
663
  // These are black holes, we'll ignore what's in them
629
664
  HtmlRawTag =
630
665
  | HtmlRawTagImpl<"script">
@@ -730,9 +765,12 @@ StrictLiquidHTML <: LiquidHTML {
730
765
  WithPlaceholderLiquid <: Liquid {
731
766
  liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
732
767
  liquidTagRenderMarkup :=
768
+ liquidString<delimTag> renderVariableExpression? renderAliasExpression? completionModeRenderArguments
769
+ liquidTagIncludeMarkup :=
733
770
  partialExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
734
771
  liquidTagName := (letter | "█") (alnum | "_")*
735
772
  variableSegment := (letter | "_" | "█") (identifierCharacter | "█")*
773
+ dotLookupName := (alnum | "_" | "█") (~endOfTagName (identifierCharacter | "█"))* "?"?
736
774
  liquidDoc :=
737
775
  liquidDocStart
738
776
  liquidDocBody
@@ -742,9 +780,12 @@ WithPlaceholderLiquid <: Liquid {
742
780
  WithPlaceholderLiquidStatement <: LiquidStatement {
743
781
  liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
744
782
  liquidTagRenderMarkup :=
783
+ liquidString<delimTag> renderVariableExpression? renderAliasExpression? completionModeRenderArguments
784
+ liquidTagIncludeMarkup :=
745
785
  partialExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
746
786
  liquidTagName := (letter | "█") (alnum | "_")*
747
787
  variableSegment := (letter | "_" | "█") (identifierCharacter | "█")*
788
+ dotLookupName := (alnum | "_" | "█") (~endOfTagName (identifierCharacter | "█"))* "?"?
748
789
  liquidDoc :=
749
790
  liquidDocStart
750
791
  liquidDocBody
@@ -754,9 +795,12 @@ WithPlaceholderLiquidStatement <: LiquidStatement {
754
795
  WithPlaceholderLiquidHTML <: LiquidHTML {
755
796
  liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
756
797
  liquidTagRenderMarkup :=
798
+ liquidString<delimTag> renderVariableExpression? renderAliasExpression? completionModeRenderArguments
799
+ liquidTagIncludeMarkup :=
757
800
  partialExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
758
801
  liquidTagName := (letter | "█") (alnum | "_")*
759
802
  variableSegment := (letter | "_" | "█") (identifierCharacter | "█")*
803
+ dotLookupName := (alnum | "_" | "█") (~endOfTagName (identifierCharacter | "█"))* "?"?
760
804
  leadingTagNameTextNode := (letter | "█") (alnum | "-" | ":" | "█")*
761
805
  trailingTagNameTextNode := (alnum | "-" | ":" | "█")+
762
806
  liquidDoc :=
@@ -106,7 +106,7 @@ Liquid <: Helpers {
106
106
 
107
107
  liquidTagOpenGraphQL = liquidTagOpenRule<"graphql", liquidTagGraphQLInlineMarkup>
108
108
  // Use negative lookahead to exclude file-based syntax (with "=")
109
- liquidTagGraphQLInlineMarkup = variableSegment ~(space* "=") graphqlRenderArguments
109
+ liquidTagGraphQLInlineMarkup = variableSegment ~(space* "=") graphqlRenderArguments liquidFilter<delimTag>* space*
110
110
 
111
111
  liquidTagOpen =
112
112
  | liquidTagOpenStrict
@@ -201,25 +201,28 @@ Liquid <: Helpers {
201
201
  liquidTagContentForMarkup = contentForType space*
202
202
  contentForType = liquidString<delimTag>
203
203
 
204
- liquidTagInclude = liquidTagRule<"include", liquidTagRenderMarkup>
204
+ liquidTagInclude = liquidTagRule<"include", liquidTagIncludeMarkup>
205
+ liquidTagIncludeMarkup =
206
+ partialExpression renderVariableExpression? renderAliasExpression? renderArguments
207
+
205
208
  liquidTagRender = liquidTagRule<"render", liquidTagRenderMarkup>
206
209
  liquidTagRenderMarkup =
207
- partialExpression renderVariableExpression? renderAliasExpression? renderArguments
210
+ liquidString<delimTag> renderVariableExpression? renderAliasExpression? renderArguments
208
211
 
209
212
  liquidTagFunction = liquidTagRule<"function", liquidTagFunctionMarkup>
210
- liquidTagFunctionMarkup = variableSegment space* "=" space* partialExpression renderArguments
213
+ liquidTagFunctionMarkup = liquidVariableLookup<delimTag> space* "=" space* partialExpression renderArguments liquidFilter<delimTag>* space*
211
214
 
212
215
  liquidTagGraphQL = liquidTagRule<"graphql", liquidTagGraphQLMarkup>
213
- liquidTagGraphQLMarkup = variableSegment space* "=" space* partialExpression graphqlRenderArguments
216
+ liquidTagGraphQLMarkup = variableSegment space* "=" space* partialExpression graphqlRenderArguments liquidFilter<delimTag>* space*
214
217
 
215
218
  // platformos simple tags
216
219
  liquidTagBackground = liquidTagRule<"background", liquidTagBackgroundMarkup>
217
220
  liquidTagBackgroundMarkup = variableSegment space* "=" space* partialExpression renderArguments
218
221
 
219
222
  liquidTagOpenBackground = liquidTagOpenRule<"background", liquidTagBackgroundInlineMarkup>
223
+ // Block form: only named arguments, no result variable (matches Ruby inline syntax)
220
224
  // Use negative lookahead to exclude file-based syntax (with "=")
221
- // jobId is required before any arguments
222
- liquidTagBackgroundInlineMarkup = ~(variableSegment space* "=") variableSegmentAsLookup argumentSeparatorOptionalComma tagArguments space*
225
+ liquidTagBackgroundInlineMarkup = ~(variableSegment space* "=") argumentSeparatorOptionalComma tagArguments space*
223
226
 
224
227
  liquidTagOpenCache = liquidTagOpenRule<"cache", liquidTagCacheMarkup>
225
228
  liquidTagCacheMarkup = liquidExpression<delimTag> renderArguments
@@ -231,23 +234,34 @@ Liquid <: Helpers {
231
234
 
232
235
  liquidTagOpenTry = liquidTagOpenRule<"try", empty>
233
236
 
234
- liquidTagCatch = liquidTagRule<"catch", variableSegmentAsLookupMarkup>
237
+ liquidTagCatch = liquidTagRule<"catch", liquidTagCatchMarkup>
238
+ liquidTagCatchMarkup = variableSegmentAsLookup? space*
235
239
 
236
240
  liquidTagLog = liquidTagRule<"log", liquidTagLogMarkup>
237
- liquidTagLogMarkup = liquidExpression<delimTag> renderArguments
241
+ liquidTagLogMarkup = liquidExpression<delimTag> liquidTagLogArguments
242
+ liquidTagLogArguments = (argumentSeparatorOptionalComma logArguments) (space* ",")? space*
243
+ logArguments = listOf<logArgument<delimTag>, argumentSeparatorOptionalComma>
244
+ logArgument<delim> = namedArgument<delim> | positionalArgument<delim>
238
245
 
239
246
  liquidTagPrint = liquidTagRule<"print", liquidTagEchoMarkup>
240
247
 
241
- liquidTagReturn = liquidTagRule<"return", liquidTagEchoMarkup>
248
+ liquidTagReturn = liquidTagRule<"return", liquidTagReturnMarkup>
249
+ liquidTagReturnMarkup = liquidReturnVariable<delimTag>? space*
250
+ liquidReturnVariable<delim> = liquidReturnExpression<delim> liquidFilter<delim>* space* &delim
251
+ liquidReturnExpression<delim> =
252
+ | liquidJsonHashLiteral<delim>
253
+ | liquidJsonArrayLiteral<delim>
254
+ | liquidComplexExpression<delim>
242
255
 
243
256
  liquidTagYield = liquidTagRule<"yield", liquidTagYieldMarkup>
244
257
  liquidTagYieldMarkup = liquidExpression<delimTag> space*
245
258
 
246
259
  liquidTagSession = liquidTagRule<"session", liquidTagSessionMarkup>
247
- liquidTagSessionMarkup = variableSegment space* "=" space* liquidExpression<delimTag> space*
260
+ liquidTagSessionMarkup = variableSegment space* "=" space* liquidVariable<delimTag> space*
248
261
 
249
262
  liquidTagExport = liquidTagRule<"export", liquidTagExportMarkup>
250
- liquidTagExportMarkup = nonemptyListOf<exportVariable, argumentSeparator> argumentSeparatorOptionalComma namedArgument<delimTag> space*
263
+ liquidTagExportMarkup = nonemptyListOf<exportVariable, argumentSeparator> liquidTagExportNamespace? space*
264
+ liquidTagExportNamespace = argumentSeparatorOptionalComma namedArgument<delimTag>
251
265
  // Variable lookup that is NOT followed by ":" (to distinguish from named arguments)
252
266
  exportVariable = variableSegmentAsLookup ~(space* ":")
253
267
 
@@ -269,7 +283,7 @@ Liquid <: Helpers {
269
283
  liquidTagThemeRenderRc = liquidTagRule<"theme_render_rc", liquidTagRenderMarkup>
270
284
 
271
285
  liquidTagResponseStatus = liquidTagRule<"response_status", liquidTagResponseStatusMarkup>
272
- liquidTagResponseStatusMarkup = liquidNumber space*
286
+ liquidTagResponseStatusMarkup = (liquidNumber | liquidVariableLookup<delimTag>) space*
273
287
 
274
288
  liquidTagResponseHeaders = liquidTagRule<"response_headers", liquidTagResponseHeadersMarkup>
275
289
  liquidTagResponseHeadersMarkup = liquidExpression<delimTag> space*
@@ -278,7 +292,7 @@ Liquid <: Helpers {
278
292
 
279
293
  renderArguments = (argumentSeparatorOptionalComma tagArguments) (space* ",")? space*
280
294
  completionModeRenderArguments = (argumentSeparatorOptionalComma tagArguments) (space* ",")? space* (argumentSeparator? liquidVariableLookup<delimTag> space*)?
281
- partialExpression = liquidString<delimTag> | variableSegmentAsLookup
295
+ partialExpression = liquidString<delimTag> | liquidVariableLookup<delimTag>
282
296
  renderVariableExpression = space+ ("for" | "with") space+ liquidExpression<delimTag>
283
297
  renderAliasExpression = space+ "as" space+ variableSegment
284
298
 
@@ -427,7 +441,8 @@ Liquid <: Helpers {
427
441
  | indexLookup<delim>
428
442
  | dotLookup
429
443
  indexLookup<delim> = space* "[" space* liquidExpression<delim> space* "]"
430
- dotLookup = space* "." space* identifier
444
+ dotLookup = space* "." space* dotLookupName
445
+ dotLookupName = (alnum | "_") (~endOfTagName identifierCharacter)* "?"?
431
446
 
432
447
  liquidFilter<delim> = space* "|" space* identifier (space* ":" space* arguments<delim> (space* ",")?)?
433
448
 
@@ -435,11 +450,13 @@ Liquid <: Helpers {
435
450
  argumentSeparator = space* "," space*
436
451
  argumentSeparatorOptionalComma = space* ","? space*
437
452
  positionalArgument<delim> = liquidExpression<delim> ~(space* ":")
438
- namedArgument<delim> = variableSegment space* ":" space* liquidExpression<delim>
453
+ namedArgument<delim> = variableSegment space* ":" space* namedArgumentValue<delim>
454
+ namedArgumentValue<delim> = hashPairValue<delim> | liquidExpression<delim>
455
+ hashPairValue<delim> = variableSegment space* ":" space* liquidExpression<delim>
439
456
  tagArguments = listOf<namedArgument<delimTag>, argumentSeparatorOptionalComma>
440
457
  graphqlArguments = listOf<graphqlNamedArgument, argumentSeparatorOptionalComma>
441
458
  graphqlNamedArgument = variableSegment space* ":" space* graphqlNamedArgumentValue
442
- graphqlNamedArgumentValue = liquidExpression<delimTag> liquidFilter<delimTag>*
459
+ graphqlNamedArgumentValue = liquidExpression<delimTag>
443
460
  graphqlRenderArguments = (argumentSeparatorOptionalComma graphqlArguments) (space* ",")? space*
444
461
  filterArguments<delim> =
445
462
  | complexArguments<delim>
@@ -481,7 +498,10 @@ Liquid <: Helpers {
481
498
  }
482
499
 
483
500
  LiquidStatement <: Liquid {
484
- Node := listOf<LiquidStatement, statementSep> (space | newline)*
501
+ // Trailing ";"? and "#..." comment are consumed by Node and statementSep; the ${"`"};?${"`"}/${"`"}#${"`"} in
502
+ // liquidStatementEnd make &delimTag succeed before them so expression rules terminate correctly.
503
+ // tagMarkup uses liquidLineEnd (newline|end only) so inline-comment text is never truncated.
504
+ Node := listOf<LiquidStatement, statementSep> ";"? ("#" (~newline any)*)? (space | newline)*
485
505
 
486
506
  // This is the big brains moment: we redefine space to exclude newlines.
487
507
  //
@@ -547,12 +567,23 @@ LiquidStatement <: Liquid {
547
567
  liquidInlineComment
548
568
  := "#" space? tagMarkup &liquidStatementEnd
549
569
 
550
- tagMarkup := anyExceptStar<liquidStatementEnd>
570
+ // tagMarkup uses liquidLineEnd (newline|end) so that raw # text is never cut off
571
+ // (liquidInlineComment content, base-case tag markup, close-tag markup).
572
+ liquidLineEnd = newline | end
573
+ tagMarkup := anyExceptStar<liquidLineEnd>
551
574
 
552
- // trailing whitespace, newline, + anything else before the next tag
553
- statementSep = space* newline (space | newline)*
575
+ // Override string rules so that '#' inside string content is never mistaken for a
576
+ // delimTag inline-comment marker. In LiquidStatement, delimTag includes ${"`"}# ...${"`"} which
577
+ // would otherwise cause anyExceptStar<delim> to stop inside strings like '##label##'.
578
+ // Strings in liquid blocks end at the matching quote or at a newline (no multi-line strings).
579
+ liquidSingleQuotedString<delim> := "'" anyExceptStar<("'" | newline | end)> "'"
580
+ liquidDoubleQuotedString<delim> := "\"" anyExceptStar<("\"" | newline | end)> "\""
554
581
 
555
- liquidStatementEnd = newline | end
582
+ // trailing whitespace, newline, + optional leading ${"`"};${"`"} and ${"`"}# comment${"`"} before the next tag
583
+ statementSep = space* ";"? space* ("#" (~newline any)*)? newline (space | newline)*
584
+
585
+ // delimTag is used as &delim lookahead in expression rules; it must succeed before ${"`"};${"`"} and ${"`"}#${"`"}
586
+ liquidStatementEnd = ";"? space* ("#" (~newline any)*)? (newline | end)
556
587
  delimTag := liquidStatementEnd
557
588
  }
558
589
 
@@ -611,6 +642,7 @@ LiquidHTML <: Liquid {
611
642
  HtmlNode =
612
643
  | HtmlDoctype
613
644
  | HtmlComment
645
+ | HtmlProcessingInstruction
614
646
  | HtmlRawTag
615
647
  | HtmlVoidElement
616
648
  | HtmlSelfClosingElement
@@ -625,6 +657,9 @@ LiquidHTML <: Liquid {
625
657
 
626
658
  HtmlComment = "<!--" #(anyExceptStar<"-->"> "-->")
627
659
 
660
+ // Handles XML declarations (<?xml ...?>) and other processing instructions (<?...?>)
661
+ HtmlProcessingInstruction = "<?" #(anyExceptStar<"?>"> "?>")
662
+
628
663
  // These are black holes, we'll ignore what's in them
629
664
  HtmlRawTag =
630
665
  | HtmlRawTagImpl<"script">
@@ -730,9 +765,12 @@ StrictLiquidHTML <: LiquidHTML {
730
765
  WithPlaceholderLiquid <: Liquid {
731
766
  liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
732
767
  liquidTagRenderMarkup :=
768
+ liquidString<delimTag> renderVariableExpression? renderAliasExpression? completionModeRenderArguments
769
+ liquidTagIncludeMarkup :=
733
770
  partialExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
734
771
  liquidTagName := (letter | "█") (alnum | "_")*
735
772
  variableSegment := (letter | "_" | "█") (identifierCharacter | "█")*
773
+ dotLookupName := (alnum | "_" | "█") (~endOfTagName (identifierCharacter | "█"))* "?"?
736
774
  liquidDoc :=
737
775
  liquidDocStart
738
776
  liquidDocBody
@@ -742,9 +780,12 @@ WithPlaceholderLiquid <: Liquid {
742
780
  WithPlaceholderLiquidStatement <: LiquidStatement {
743
781
  liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
744
782
  liquidTagRenderMarkup :=
783
+ liquidString<delimTag> renderVariableExpression? renderAliasExpression? completionModeRenderArguments
784
+ liquidTagIncludeMarkup :=
745
785
  partialExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
746
786
  liquidTagName := (letter | "█") (alnum | "_")*
747
787
  variableSegment := (letter | "_" | "█") (identifierCharacter | "█")*
788
+ dotLookupName := (alnum | "_" | "█") (~endOfTagName (identifierCharacter | "█"))* "?"?
748
789
  liquidDoc :=
749
790
  liquidDocStart
750
791
  liquidDocBody
@@ -754,9 +795,12 @@ WithPlaceholderLiquidStatement <: LiquidStatement {
754
795
  WithPlaceholderLiquidHTML <: LiquidHTML {
755
796
  liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
756
797
  liquidTagRenderMarkup :=
798
+ liquidString<delimTag> renderVariableExpression? renderAliasExpression? completionModeRenderArguments
799
+ liquidTagIncludeMarkup :=
757
800
  partialExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
758
801
  liquidTagName := (letter | "█") (alnum | "_")*
759
802
  variableSegment := (letter | "_" | "█") (identifierCharacter | "█")*
803
+ dotLookupName := (alnum | "_" | "█") (~endOfTagName (identifierCharacter | "█"))* "?"?
760
804
  leadingTagNameTextNode := (letter | "█") (alnum | "-" | ":" | "█")*
761
805
  trailingTagNameTextNode := (alnum | "-" | ":" | "█")+
762
806
  liquidDoc :=
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformos/liquid-html-parser",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
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",