Skip to content

Commit

Permalink
Add fixes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
czosel committed Mar 21, 2021
1 parent a9aaeca commit 8f00058
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
19 changes: 10 additions & 9 deletions components/prism-jexl.js
@@ -1,13 +1,14 @@
Prism.languages.jexl = {
string: /(["'])(?:\\(?:[\s\S])|(?!\1)[^\\])*\1/,
transform: {
pattern: /\|\s*[a-zA-Zа-яА-Я_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$][a-zA-Zа-яА-Я0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$]*/,
'string': /(["'])(?:\\[\s\S]|(?!\1)[^\\])*\1/,
'transform': {
pattern: /(\|)\s*[a-zA-Zа-яА-Я_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$][a-zA-Zа-яА-Я0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$]*/,
alias: "function",
lookbehind: true
},
function: /[a-zA-Zа-яА-Я_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$][a-zA-Zа-яА-Я0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$]*\s*(?=\()/,
number: /\b(?:(?:\d*\.\d+)|\d+)/,
operator: /[<>]=?|[!=]=?|-|\+|&&|\|\||\/\/?|[?:*^%]/,
boolean: /\b(?:true|false)\b/,
keyword: /\bin\b/,
punctuation: /[{}[\](),.]/,
'function': /[a-zA-Zа-яА-Я_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$][a-zA-Zа-яА-Я0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$]*\s*(?=\()/,
'number': /\b\d+(?:\.\d+)?\b|\B\.\d+\b/,
'operator': /[<>!]=?|-|\+|&&|==|\|\|?|\/\/?|[?:*^%]/,
'boolean': /\b(?:true|false)\b/,
'keyword': /\bin\b/,
'punctuation': /[{}[\](),.]/,
};
4 changes: 2 additions & 2 deletions tests/languages/jexl/operator_feature.test
Expand Up @@ -2,7 +2,7 @@
+
< <=
> >=
= ==
==
! !=
&& ||
*
Expand All @@ -18,7 +18,7 @@
["operator", "+"],
["operator", "<"], ["operator", "<="],
["operator", ">"], ["operator", ">="],
["operator", "="], ["operator", "=="],
["operator", "=="],
["operator", "!"], ["operator", "!="],
["operator", "&&"], ["operator", "||"],
["operator", "*"],
Expand Down
17 changes: 10 additions & 7 deletions tests/languages/jexl/transform_feature.test
Expand Up @@ -15,28 +15,31 @@ foo|bar(
----------------------------------------------------

[
["string", "\"foo\""], ["transform", "|bar"],
["string", "\"foo\""], ["transform", "| bar"],
["string", "\"foo\""], ["operator", "|"], ["transform", "bar"],
["string", "\"foo\""], ["operator", "|"], ["transform", " bar"],
["string", "\"foo\""],
["transform", "| \r\nbar"],
["operator", "|"], ["transform", " \r\nbar"],

"\r\n\r\nfoo", ["transform", "|Ý"],
"\r\n\r\nfoo", ["operator", "|"], ["transform", "Ý"],

"\r\n\r\nfoo",
["transform", "|bar"],
["operator", "|"],
["transform", "bar"],
["punctuation", "("],
["punctuation", ")"],

"\r\nfoo",
["transform", "|bar"],
["operator", "|"],
["transform", "bar"],
["punctuation", "("],
["number", "1"],
["punctuation", ","],
["number", "2"],
["punctuation", ")"],

"\r\nfoo",
["transform", "|bar"],
["operator", "|"],
["transform", "bar"],
["punctuation", "("],

["number", "1"],
Expand Down

0 comments on commit 8f00058

Please sign in to comment.