diff --git a/components/prism-liquid.js b/components/prism-liquid.js index 487dcc5db6..2cd40fc1a7 100644 --- a/components/prism-liquid.js +++ b/components/prism-liquid.js @@ -32,7 +32,11 @@ Prism.languages.liquid = { // https://github.com/Shopify/liquid/blob/698f5e0d967423e013f6169d9111bd969bd78337/lib/liquid/lexer.rb#L21 'number': /\b\d+(?:\.\d+)?\b/, 'operator': /[!=]=|<>|[<>]=?|[|?:=-]|\b(?:and|or|contains(?=\s))\b/, - 'punctuation': /[.,\[\]()]/ + 'punctuation': /[.,\[\]()]/, + 'empty': { + pattern: /empty/, + alias: 'keyword' + }, }; Prism.hooks.add('before-tokenize', function (env) { diff --git a/tests/languages/liquid/empty_feature.test b/tests/languages/liquid/empty_feature.test new file mode 100644 index 0000000000..59a9e33f2f --- /dev/null +++ b/tests/languages/liquid/empty_feature.test @@ -0,0 +1,78 @@ +{% unless pages == empty %} + +

{{ pages.frontpage.title }}

+
{{ pages.frontpage.content }}
+{% endunless %} + +---------------------------------------------------- + +[ + ["liquid", [ + ["delimiter", "{%"], + ["keyword", "unless"], + " pages ", + ["operator", "=="], + ["empty", "empty"], + ["delimiter", "%}"] + ]], + + ["comment", ""], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "h1" + ]], + ["punctuation", ">"] + ]], + ["liquid", [ + ["delimiter", "{{"], + " pages", + ["punctuation", "."], + "frontpage", + ["punctuation", "."], + "title ", + ["delimiter", "}}"] + ]], + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["punctuation", ">"] + ]], + ["liquid", [ + ["delimiter", "{{"], + " pages", + ["punctuation", "."], + "frontpage", + ["punctuation", "."], + "content ", + ["delimiter", "}}"] + ]], + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]], + + ["liquid", [ + ["delimiter", "{%"], + ["keyword", "endunless"], + ["delimiter", "%}"] + ]] +] + +---------------------------------------------------- + +Test for the 'empty' keyword / special thing.