Shopify / prettier-plugin-liquid

Prettier Liquid/HTML plugin
https://npm.im/@shopify/prettier-plugin-liquid
MIT License
93 stars 15 forks source link

Comments are deleted #144

Closed andyxmas closed 1 year ago

andyxmas commented 1 year ago

Describe the bug The contents between {% comment %} and {% endcomment %} tags are deleted.

Unformatted source

{% comment %} 
This is a comment
{% endcomment %}

<p>hello, world!</p>

Expected output

{% comment %} 
This is a comment
{% endcomment %}

<p>hello, world!</p>

Actual output

{% comment %}

{% endcomment %}

<p>hello, world!</p>

Debugging information

Additional context I find this issue when running from the command line like npx prettier sections/test.liquid --write or from the plugin on vscode. I've deleted my .prettier.congig.js

Thanks for you work on this plugin - I'm really keen to adopt it in our workflow, but I've never tested beyond this issue as its a definite blocker.

charlespwd commented 1 year ago

This seems related to the two whitespace character after the opening block:

{% comment %} 
This is a comment

is actually {% comment %} \nThis is a comment.

When I don't have them, this doesn't happen. So odd that we never caught that before. Thanks for reporting!

andyxmas commented 1 year ago

@charlespwd ah, you're right. I've set "editor.renderWhitespace": "all" in my vscode settings, and I see it now. I shall delete the white space and continue testing!

charlespwd commented 1 year ago

I mean, that's still definetly an urgent bug that I just fixed :) It's going into v1.0.1 and will be released today.

charlespwd commented 1 year ago

Shipped in v1.0.1, thanks again for reporting :)