First commit of "advanced" MCI formatting via theme.hjson entries allowing mini-formatting langauge to apply
Example: {BN!styleFirstLower} in 'text' property
This commit is contained in:
@@ -22,6 +22,7 @@ const moment = require('moment');
|
||||
const async = require('async');
|
||||
|
||||
exports.getPredefinedMCIValue = getPredefinedMCIValue;
|
||||
exports.getPredefinedMCIFormatObject = getPredefinedMCIFormatObject;
|
||||
exports.init = init;
|
||||
|
||||
function init(cb) {
|
||||
@@ -532,3 +533,21 @@ function getPredefinedMCIValue(client, code, extra) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
function getPredefinedMCIFormatObject(client, text) {
|
||||
const re = /\{([A-Z]{2})(?:[!:][^}]+)?\}/g;
|
||||
let m;
|
||||
const formatObj = {};
|
||||
while ((m = re.exec(text))) {
|
||||
const v = getPredefinedMCIValue(client, m[1]);
|
||||
if (v) {
|
||||
if (!isNaN(v)) {
|
||||
formatObj[m[1]] = parseInt(v);
|
||||
} else {
|
||||
formatObj[m[1]] = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _.isEmpty(formatObj) ? null : formatObj;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user