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

Adds liquidjs as an AST implementation #716

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"jscodeshift": "^0.11.0",
"json-stringify-safe": "^5.0.1",
"json-to-ast": "^2.1.0",
"liquidjs": "^10.10.2",
"lodash.isequal": "^4.5.0",
"luaparse": "^0.3.0",
"lucene": "^2.1.1",
Expand Down
11 changes: 11 additions & 0 deletions website/src/parsers/liquid/codeExample.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% assign people = "alice, bob, carol" | split: ", " -%}

<ul>
{%- for person in people %}
<li>
<a href="{{person | prepend: "http://example.com/"}}">
{{ person | capitalize }}
</a>
</li>
{%- endfor%}
</ul>
7 changes: 7 additions & 0 deletions website/src/parsers/liquid/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// TODO: Add code mirror for liquid
// import 'codemirror/mode/clike/clike';

export const id = 'text/liquid';
export const displayName = 'Liquid';
export const mimeTypes = [];
export const fileExtension = 'liquid';
31 changes: 31 additions & 0 deletions website/src/parsers/liquid/liquidjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import defaultParserInterface from '../utils/defaultParserInterface';
import pkg from 'json-to-ast/package.json';

const ID = 'liquidjs';

export default {
...defaultParserInterface,

id: ID,
displayName: ID,
version: pkg.version,
homepage: pkg.homepage,
locationProps: new Set(['loc']),

loadParser(callback) {
require(['liquidjs'], callback);
},

parse(liquid, code) {
return new liquid.Liquid().parse(code);
},

nodeToRange({loc}) {
if (loc) {
return [
loc.start.offset,
loc.end.offset,
];
}
},
}
12 changes: 12 additions & 0 deletions website/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3844,6 +3844,11 @@ [email protected]:
dependencies:
graceful-readlink ">= 1.0.0"

commander@^10.0.0:
version "10.0.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06"
integrity sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==

commander@^2.12.1, commander@^2.20.0, commander@^2.5.0, commander@~2.20.3:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
Expand Down Expand Up @@ -7206,6 +7211,13 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=

liquidjs@^10.10.2:
version "10.10.2"
resolved "https://registry.yarnpkg.com/liquidjs/-/liquidjs-10.10.2.tgz#e49da58989de3f00fcad0e613c1e589d76abec2f"
integrity sha512-UcuTUexKg/8CmX6I5KNghk13pl3c8Rqhm+WSWqrc17pQP9LjpYPpOLDKG9OMBeHDBQ70yyn/GOqyZ/EKJ4z5yg==
dependencies:
commander "^10.0.0"

load-json-file@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8"
Expand Down