This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
LiquidHTMLParsingError throws error for <details> tag #213
Labels
bug
Something isn't working
Comments
mzachdev
changed the title
LiquidHTMLParsingError throws error when it shouldn't
LiquidHTMLParsingError throws error for <details> tag
Nov 10, 2023
This happens because we have to strike a balance between the following two things:
The heuristic we chose is that we only allow "two unclosed" or "two closing" HTML nodes inside Liquid branches. What we have here is an unclosed node and summary and it's very hard for us to tell that it actually closes much later down the file. It's also unclear how we're supposed to indent the code in this situation. You could fix this by adding an endif and re-adding the if statement between the unclosed node and the child node. {% # works because there's only one unclosed node here %}
{% if is_megamenu or has_dropdown %}
<details
data-hover="{{ hover_menu }}"
id="site-nav-item--{{ forloop.index }}"
class="site-nav__details"
>
{% endif %}
{% if is_megamenu or has_dropdown %}
<summary
data-link="{{ link.url }}"
aria-expanded="false"
aria-controls="site-nav-item--{{ forloop.index }}"
class="site-nav__link site-nav__link--underline{% if has_dropdown %} site-nav__link--has-dropdown{% endif %}"
>
{{ link.title }}
<svg
aria-hidden="true"
focusable="false"
role="presentation"
class="icon icon--wide icon-chevron-down"
viewBox="0 0 28 16"
>
<path d="m1.57 1.59 12.76 12.77L27.1 1.59" stroke-width="2" stroke="#000" fill="none"/>
</svg>
</summary>
{% else %}
<a
href="{{ link.url }}"
class="site-nav__link site-nav__link--underline{% if has_dropdown %} site-nav__link--has-dropdown{% endif %}"
>
{{ link.title }}
</a>
{% endif %} |
1 task
👋 this came up too often. I think I have a fix for it in Shopify/theme-tools#253. Should be in soon :) |
charlespwd
added a commit
to Shopify/theme-tools
that referenced
this issue
Jan 9, 2024
* Small refactor of ASTBuilder for clearer push method * Move prettier integration tests to src for better vitest integration * VS Code settings changes * Add full support for unclosed HTML elements inside branching code Fixes #196 Fixes Shopify/prettier-plugin-liquid#213 * Allow 'HtmlDanglingMarkerClose' nodes to have non-dangling marker siblings We relax the heuristic to be less annoying. * Fixup extraneous spaces * Clean up unused option in ASTBuilder * Remove ieConditionalComment stuff
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
The prettier-plugin-liquid throws an error [LiquidHTMLParsingError] on a file from the Impulse theme by Archetype. The HTML tag is closed correctly, it's clearly not able to parse the code properly. The error is thrown specifically for the
<details...>
tag, which is closed all the way at the bottom of the code block.Is there a way to disable this error for this file or code block only? I'm unfamiliar with how to do that. Thanks!
Unformatted source
Debugging information
The text was updated successfully, but these errors were encountered: