diff --git a/website/package.json b/website/package.json index 6043538e..fb5e64e0 100644 --- a/website/package.json +++ b/website/package.json @@ -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", diff --git a/website/src/parsers/liquid/codeExample.txt b/website/src/parsers/liquid/codeExample.txt new file mode 100644 index 00000000..d4d0da9d --- /dev/null +++ b/website/src/parsers/liquid/codeExample.txt @@ -0,0 +1,11 @@ +{% assign people = "alice, bob, carol" | split: ", " -%} + + diff --git a/website/src/parsers/liquid/index.js b/website/src/parsers/liquid/index.js new file mode 100644 index 00000000..da982ea3 --- /dev/null +++ b/website/src/parsers/liquid/index.js @@ -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'; diff --git a/website/src/parsers/liquid/liquidjs.js b/website/src/parsers/liquid/liquidjs.js new file mode 100644 index 00000000..8d1d8f69 --- /dev/null +++ b/website/src/parsers/liquid/liquidjs.js @@ -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, + ]; + } + }, +} diff --git a/website/yarn.lock b/website/yarn.lock index fe8e9dd8..c3e03bbb 100644 --- a/website/yarn.lock +++ b/website/yarn.lock @@ -3844,6 +3844,11 @@ commander@2.9.x: 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" @@ -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"