/** * Lax recovery of malformed Liquid markup, mirroring Ruby liquid's lax parse * mode (`Liquid::ParserSwitching` strict-then-lax fallback). * * IMPORTANT: nothing in this module is reachable from `toLiquidHtmlAST` or the * document-layer parsers. Strict parsing (the AST that `theme-check` consumes) * is completely unaffected. These helpers exist solely so the render-tree * (`@editor/liquid-render-tree`) can reproduce Ruby's *rendered output* for a * `{{ }}` / `{% %}` that already failed strict parsing and arrived as a * base-case (string-markup) node. The render-tree is not consumed by the * linter, so the linter still reports these as syntax errors. * * The recovery re-tokenizes the raw markup and re-parses it with the existing * `MarkupParser` lax mode (`enableLax()`), and — for tags — re-runs the tag's * own `parse` callback, keeping the lax grammar in one place. */ import type { LiquidExpression, LiquidVariable } from './ast'; /** * Lax-recover the `LiquidVariable` for a string-markup `{{ ... }}`. * Returns `undefined` when even lax parsing cannot produce a value (the caller * then falls back to rendering nothing / the raw string). */ export declare function laxRecoverVariable(rawMarkup: string, source: string, offset: number): LiquidVariable | undefined; /** * Lax-recover the structured markup for a base-case tag (`{% name markup %}`). * Looks up the tag definition and re-runs its `parse` callback under lax mode. * The returned value is the tag-specific markup node (`AssignMarkup`, * `LiquidVariable`, `LiquidConditionalExpression`, `ForMarkup`, …) that the * strict path would have produced. * * Unlike the variable recovery, this does NOT swallow failures into an * empty-output sentinel. Core Liquid still surfaces errors for unrecoverable or * semantically-invalid tag markup even in lax mode: an unknown tag raises via * `block.rb`, invalid assign syntax raises via `assign.rb`, and an unsupported * condition operator raises `Unknown operator …` via `condition.rb`. So this * throws a `LaxTagRecoveryError` (for an unknown tag) or propagates the parse * error (for malformed markup) instead of reducing to empty output. The * render-tree caller translates the thrown error into the rendered error * surface; only genuinely-empty lax renders return normally (the tag's own * `parse` succeeds and produces markup). */ export declare function laxRecoverTagMarkup(tagName: string, markupString: string, source: string, offset: number, markupEnd: number): unknown; /** * Raised by `laxRecoverTagMarkup` when a base-case tag cannot be recovered * because it is not a real tag. Distinct from the parser's own * `LiquidHTMLASTParsingError` (thrown for malformed markup) so the render-tree * can recognize an unknown-tag failure specifically. */ export declare class LaxTagRecoveryError extends Error { constructor(message: string); } /** * Lax-recover the value list for a `{% when ... %}` branch whose strict parse * failed (e.g. a trailing element `when 1 bar` or an invalid expression * `when foo=>bar`) and arrived as a raw string. `when` is a branch, not a * top-level tag in `builtinTags`, so it has no `TagDefinition`; its parse is * the standalone `whenBranchParse`, which consults lax mode to drop a trailing * fragment and (via the lax `variableLookup`) fold a contiguous `=>bar` into * the preceding lookup. Mirrors Ruby `parse_lax_when` (`case.rb:132-143`). * Returns `undefined` when even lax parsing fails (caller then yields no match). */ export declare function laxRecoverWhenValues(markupString: string, source: string, offset: number, markupEnd: number): LiquidExpression[] | undefined;