panoply / vscode-liquid

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

1 more end type than start type - block tag #153

Closed Daniel-Knights closed 4 months ago

Daniel-Knights commented 1 year ago

Formatting this:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta
    http-equiv="X-UA-Compatible"
    content="IE=edge"
  >
  <meta
    name="viewport"
    content="width=device-width, initial-scale=1.0"
  >
  <title>Document</title>
  <link rel="stylesheet" href="custom.css" />
</head>
<body>
  {% block %}{% endblock %}
</body>
</html>

Results in this:

ERROR: Parse error occured when formatting document

Prettify Error (line 18):
1 more end type than start type

If I remove {% block %}{% endblock %}, it formats fine.

Extension version 3.2.2.

panoply commented 1 year ago

Hey @Daniel-Knights

I will have a look at this, but I believe it is addressed in #138. Can you try adding content within the {% block %}?

Daniel-Knights commented 1 year ago

Hi, thanks @panoply. I tried with content, but get the same result

panoply commented 1 year ago

I'm not sure of the exact issue, but likely related to <body> containment. It definitely addressed and fixed in #138 - however I still need to tie up some loose ends before it is shipped. If it possible for you execute that code in an isolated manner, like within an _include or snippet file where it is not encapsulated within a <body> element, things should work.

Daniel-Knights commented 1 year ago

It does format, but the indentation isn't right:

<!DOCTYPE html>
      <html lang="en">
        <head>
          <meta charset="UTF-8">
          <meta http-equiv="X-UA-Compatible" content="IE=edge">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <title>Document</title>
          <link rel="stylesheet" href="custom.css" />
        </head>
        <body>
          {% render "block" %}
        </body>
      </html>

Also, the block tag doesn't work as it should when moved to a separate file, but that's not really relevant here.

panoply commented 4 months ago

This one is really stale but is was fixed some time ago!