vscode-liquid icon indicating copy to clipboard operation
vscode-liquid copied to clipboard

Inline JSON gets messed up

Open lmartins opened this issue 6 years ago • 7 comments
trafficstars

Hi,

I love this extension and to the most part it works pretty well. It does however mess up when you have inline schema data like this:

{% if template.name == 'index' %}
<script type="application/ld+json">
    {
      "@context": "http://schema.org",
      "@type": "WebSite",
      "name": "{{ shop.name }}",
      "potentialAction": {
        "@type": "SearchAction",
        "target": "{{ shop.url }}/search?q={search_term_string}",
        "query-input": "required name=search_term_string"
      },
      "url": "{{ shop.url }}{{ page.url }}"
    }
  </script>
{% endif %}

as it is converted to this:

<script type="application/ld+json">


[36mLine: 1[0m
[31m[36 mLine : 1 [[0m
[31m        0 m [[0m
[31m            31 m[[0m
[31m                36 mLine : 2 [[0m
[31m                    [[0m
[31m                        0 m [[0m
[31m                            31 m 0 m [[0m

</script>

{% if template.name == 'index' %}
  <script type="application/ld+json">


[36mLine: 2[0m
[31m(empty line)[0m
[31m(empty line)[0m
[31m[36mLine: 1[0m[0m
[31m[31m[36 mLine : 1 [[0m[0m
[31m[31m        0 m [[0m[0m
[31m[31m            31 m {[0m[0m
[31m[31m                [[0m[0m

</script>
{% endif %}

I've already verified that I don't have the other Liquid extensions known to cause issues, and I also have Prettier disabled on this test.

Any way I can get around this?

lmartins avatar Oct 11 '19 12:10 lmartins

Hey @lmartins this is known issue that will be fixed in the next version release. A quick workaround for now until it is addressed is to do something like this:

{% assign attr = 'type="application/ld+json"' %}

<script {{ attr }}>
  {
    "name": "foo",
    "settings": [
      {
        "type": "something"
      }
    ]
  }
</script>

panoply avatar Oct 11 '19 14:10 panoply

@panoply Thanks so much for the fast reply.

lmartins avatar Oct 11 '19 16:10 lmartins

Any updates on a fix for this?

erin-dot-io avatar Jul 23 '20 20:07 erin-dot-io

Coming. Sit tight.

panoply avatar Jul 23 '20 20:07 panoply

How to config to not format this part?

keidarcy avatar Oct 01 '20 01:10 keidarcy

Hi there! Just wanted to check - are there any new solutions to this? Thank you!

bigboydiamonds avatar Feb 15 '21 23:02 bigboydiamonds

Coming. Sit tight.

Almost end of 2021 and no fix

pinguluk avatar Dec 09 '21 17:12 pinguluk

🚢 Shipped v3.0.0

panoply avatar Sep 28 '22 08:09 panoply