Skip to content

Commit

Permalink
Added support for .properties extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
petersirka committed Sep 2, 2024
1 parent 68b3444 commit d3cd598
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app.bundle

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions public/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,69 @@ WAIT('CodeMirror.defineMode', function() {
};
});

CodeMirror.defineMode('properties', function() {

var REG_KEY = /^.*?=/i;
var REG_NUM = /^[-0-9\.\,]+$/;
var isclass = function(text) {
var count = 0;
for (let i = 0; i < text.length; i++) {
if (text.charAt(i) === '.')
count++;
if (count > 1)
return true;
}
};

return {

startState: function() {
return { type: 0, keyword: 0 };
},

token: function(stream, state) {

var m;

if (stream.sol()) {

var line = stream.string;
if (line.charAt(0) === '#') {
stream.skipToEnd();
return 'comment';
}

state.type = 0;
}

if (!state.keyword) {
m = stream.match(REG_KEY, true);
if (m) {
state.keyword = 1;
return 'property';
}
}

if (!stream.string) {
state.keyword = 0;
stream.next();
return '';
}

state.keyword = 0;
stream.skipToEnd();
let val = stream.string.substring(stream.start).trim();
if (REG_NUM.test(val))
return 'number';
if (val.includes('/'))
return 'atom';
if (isclass(val))
return 'tag';
return 'string';
}
};
});

CodeMirror.defineMode('totaljsbundle', function() {
var REG_ADD = /^\+/;
var REG_REM = /^-/;
Expand Down
3 changes: 3 additions & 0 deletions public/parts/code.html
Original file line number Diff line number Diff line change
Expand Up @@ -2577,6 +2577,9 @@
case 'bundle':
mode = 'totaljsresources';
break;
case 'properties':
mode = 'properties';
break;
case 'env':
mode = 'env';
break;
Expand Down

0 comments on commit d3cd598

Please sign in to comment.