SublimeText / Liquid

Shopify Liquid syntax for Sublime Text
https://packagecontrol.io/packages/Liquid
MIT License
18 stars 11 forks source link

Issue highlight with Liquid and Script type=“application/ld+json” #10

Closed ttnbtfy closed 11 months ago

ttnbtfy commented 11 months ago

Hi, I have an issue with the code Script with type="application/ld+json"

Not only does it have display problems, fold buttons also do not work, as the code cannot be hidden.

I'm not sure if this is a feature or a bug, can anyone confirm this for me?

I have created a discussion here, you can find more information about this issue

Sublime version: 4166 This issue does not appear on version 4107

Can you check it? Thank you.

deathaxe commented 11 months ago

Fixed by Liquid 2.2.1

Note: ST's JSON syntax is not optimized to work with templating engines. Thus there might still be some smaller highlighting issues, like illegal highlighted commas etc.

ttnbtfy commented 11 months ago

It looks a lot more comfortable but still seems unfinished, I thought I should give you this code:

<script type="application/ld+json">
    {
        "@context": "http://schema.org/",
        "@type": "Product",
        "name": {{ product.title | json }},
        "url": {{ shop.url | append: product.url | json }},
        {%- if selected_product.featured_media -%}
            {%- assign media_size = selected_product.featured_media.preview_image.width -%}
            "image": [
                {{ selected_product.featured_media | image_url: width: media_size | prepend: "https:" | json }}
            ],
        {%- endif -%}
        "description": {{ product.description | strip_html | json }},
        {%- if selected_product.sku != blank -%}
            "sku": {{ selected_product.sku | json }},
        {%- endif -%}
        "brand": {
            "@type": "Thing",
            "name": {{ product.vendor | json }}
        },
        "offers": [
            {%- for variant in product.variants -%}
                {
                    "@type" : "Offer",
                    {%- if variant.sku != blank -%}
                        "sku": {{ variant.sku | json }},
                    {%- endif -%}
                    "availability" : "http://schema.org/{% if variant.available %}InStock{% else %}OutOfStock{% endif %}",
                    "price" : {{ variant.price | divided_by: 100.00 | json }},
                    "priceCurrency" : {{ cart.currency.iso_code | json }},
                    "url" : {{ shop.url | append: variant.url | json }}
                }{% unless forloop.last %},{% endunless %}
            {%- endfor -%}
        ]
    }
</script>

Imgur Thank you for fixing it.

deathaxe commented 11 months ago

That's what I mean with "ST's JSON syntax is not optimized to work with templating engine".

It uses a lot of unnamed contexts, which can't be overridden by 3rd-party packages.

As of ST4134 JSON is highlighted within HTML Githubissues.

  • Githubissues is a development platform for aggregating issues.