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 72a511b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
19 changes: 10 additions & 9 deletions components/prism-jexl.js
Original file line number Diff line number Diff line change
@@ -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': /[{}[\](),.]/,
};
2 changes: 1 addition & 1 deletion components/prism-jexl.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/languages/jexl/operator_feature.test
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 72a511b

Please sign in to comment.