panoply / vscode-liquid

💧Liquid language support for VS Code
https://marketplace.visualstudio.com/items?itemName=sissel.shopify-liquid
Other
171 stars 22 forks source link

Formatter error when missing newline in template #130

Closed T3sT3ro closed 1 year ago

T3sT3ro commented 1 year ago

For the following file (changed language mode to liquid), formatting with liquid prints error:

<!DOCTYPE html>
<html lang="en">

  {%- include head.html title="{{ site.title }}" -%}

  <body>
    {%- include header.html -%}

    {%- comment -%}
      {%- include nav.html %}
      {%- include toolbar.html -%}
    {%- endcomment -%}

    <main>
      {%- for post in site.posts -%}
        {%- include post-card.html post=post truncate=true -%}
      {%- endfor -%}
    </main>

    {%- include footer.html -%}
  </body>
</html>

^ The important part here is to make sure, that there is no newline after closing </html> tag

In this case the error is:

ERROR: Formatting parse error occured in document

Prettify Error:

1 more end type than start types
panoply commented 1 year ago

Hey @T3sT3ro

This is definitely a bug. It seems to occur when using delimiter trims (ie: {%-) for comment block tags. I'll ship a patch as soon as I can. Thanks for reporting.