Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves Liquid Support #5098

Merged
merged 7 commits into from
Mar 28, 2023
Merged

Improves Liquid Support #5098

merged 7 commits into from
Mar 28, 2023

Conversation

panoply
Copy link
Contributor

@panoply panoply commented Mar 20, 2023

This PR overhauls Liquid grammar mode and brings support for embedded code regions and introduces a more refined approach to dealing with custom Liquid variations in circulation. The most notable changes are as follows:

External Code Regions

In the Shopify Liquid variation, external code regions are a thing. This PR brings support for:

  1. {% schema %} - JSON Language
  2. {% style %} - CSS Language
  3. {% stylesheet %} CSS Language
  4. {% javascript %} JavaScript Language

Allow any filter or tag name expression be provided

The previous approach of the Liquid grammar in Ace would apply highlighting according to a predetermined list of tag and filter names. This is not applicable given that custom tags and filter can be made available in different variations. This PR sloves that using grammars which determine highlighting according to syntactic structures.

Support Line Comments

Liquid now support line comment tokens, e.g: {% # comment %} which are singleton types. This PR brings support for this.

Purged Token Mode Test File

Unsure of the exact appropriation logic for the tokens_liquid.json file but presume it was introduced and used in older legacy versions of Ace. Given the overhaul applied in this PR and new token names used to describe syntax formations results in a test failure because matching assertions differ based on the changes. I would happily produce exhaustive coverage here but I don't have that much time on my hands and found it difficult to follow generation guide. In any sense, the things work fine and I tested across all tm's.

Updated Kitchen Sink Sample

Logical changes applied to the liquid.liquid kitchen sink file.

Brings support for Shopify Liquid Variation embedded code blocks which include:

- {% schema %}
- {% javascript %}
- {% style %}
- {% stylesheet %}

In addition, line comment highlighting is now provided.
},
{
token: "keyword.block",
regex: /(?<={%-?)\s*([a-zA-Z_$][a-zA-Z0-9_$]+\b)/,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are failing because node 12 doesn't support backreference in regexp, could we remove backreferences by using an additional state, or matching both the brace and the word in one rule with array token?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problems, I'll sort it today

@panoply
Copy link
Contributor Author

panoply commented Mar 23, 2023

This should clean things up.

@codecov
Copy link

codecov bot commented Mar 23, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.10 🎉

Comparison is base (469ea5d) 86.60% compared to head (c0f3843) 86.71%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5098      +/-   ##
==========================================
+ Coverage   86.60%   86.71%   +0.10%     
==========================================
  Files         555      554       -1     
  Lines       42931    42953      +22     
  Branches     6697     6691       -6     
==========================================
+ Hits        37181    37246      +65     
+ Misses       5750     5707      -43     
Flag Coverage Δ
unittests 86.71% <100.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/mode/_test/highlight_rules_test.js 63.74% <100.00%> (ø)
src/mode/liquid.js 69.23% <100.00%> (+3.51%) ⬆️
src/mode/liquid_highlight_rules.js 100.00% <100.00%> (ø)

... and 5 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@andrewnester andrewnester merged commit 0ae8dbb into ajaxorg:master Mar 28, 2023
@andrewnester
Copy link
Contributor

Merged, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants