Shopify / Shopify/theme-tools

LiquidHTMLSyntaxError false positive with dynamic html tag

Open
#1,155 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
234
Forks
92
Avg merge
1d 3h
Merged PRs (30d)
6

Description

The @shopify/liquid-html-parser package throws LiquidHTMLSyntaxError for the following code:

<{% if true %}div{% endif %}></{% if true %}div{% endif %}>

Full error:

SyntaxError: expected a letter, "{{", "wbr" (case-insensitive), "track" (case-insensitive), "source" (case-insensitive), "param" (case-insensitive), "meta" (case-insensitive), "link" (case-insensitive), "keygen" (case-insensitive), "input" (case-insensitive), "img" (case-insensitive), "hr" (case-insensitive), "embed" (case-insensitive), "command" (case-insensitive), "col" (case-insensitive), "br" (case-insensitive), "base" (case-insensitive), "area" (case-insensitive), "svg", "style", or "script"

I'd expect this syntax to be supported rather than throwing an error.

This syntax existed in older versions of the Dawn theme (example), although the theme has now been changed to work around it. This is how the issue presents in the theme editor:

Image

Reproducible with:

  • Shopify theme editor
  • Programmatic use of @shopify/liquid-html-parser

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the @shopify/liquid-html-parser package and reproduce the reported dynamic-tag example. Trace how the parser handles the opening and closing tags, then verify that the snippet is accepted without a LiquidHTMLSyntaxError and that existing parsing behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.