Skip to content

Commit d24cf68

Browse files
committed
hljs: consolidate keyword handling
Signed-off-by: Felipe Contreras <[email protected]>
1 parent 049ecd6 commit d24cf68

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

hljs/mathjs.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function mathjs(hljs) {
44
}
55

66
function keywords(args) {
7-
return '\\b' + either(args.split(' ')) + '\\b';
7+
return '\\b' + either(args) + '\\b';
88
}
99

1010
const OPERATORS = {
@@ -14,12 +14,12 @@ function mathjs(hljs) {
1414

1515
const OPERATOR_KEYWORDS = {
1616
scope: 'operator',
17-
begin: keywords('to in and not or xor mod'),
17+
begin: keywords(['to', 'in', 'and', 'not', 'or', 'xor', 'mod']),
1818
};
1919

2020
const NUMBER_KEYWORDS = {
2121
scope: 'number',
22-
begin: keywords('true false end'),
22+
begin: keywords(['true', 'false', 'end']),
2323
};
2424

2525
const UNIT_LIST = Object.keys(math.Unit.UNITS).sort((a, b) => b.length - a.length);
@@ -32,7 +32,7 @@ function mathjs(hljs) {
3232

3333
const UNITS = {
3434
scope: 'unit',
35-
begin: '\\b' + either(PREFIXED_UNIT_LIST) + '\\b',
35+
begin: keywords(PREFIXED_UNIT_LIST),
3636
};
3737

3838
const MATRIX = {
@@ -44,7 +44,7 @@ function mathjs(hljs) {
4444

4545
const FUNCTIONS = {
4646
scope: 'function',
47-
begin: '\\b' + either(FUNCTION_LIST) + '\\b',
47+
begin: keywords(FUNCTION_LIST),
4848
};
4949

5050
const VARIABLE = {

0 commit comments

Comments
 (0)