Fixed minor issues
This commit is contained in:
parent
bff57b7c0f
commit
d53f61ee2c
1 changed files with 17 additions and 17 deletions
|
|
@ -19,22 +19,22 @@ const levelMapping = [
|
||||||
const styles = Object.create(null);
|
const styles = Object.create(null);
|
||||||
|
|
||||||
function parseTaggedString(string) {
|
function parseTaggedString(string) {
|
||||||
const tagPattern = /\<([\w, '().]+)\>([\s\S]+)\<\/\w*\>/g;
|
const tagPattern = /<([\w, '().]+)>([\s\S]+)<\/\w*>/g;
|
||||||
const callPattern = /\((.*)\)/;
|
const callPattern = /\((.*)\)/;
|
||||||
return string.replace(tagPattern, (_, color, text) => {
|
return string.replace(tagPattern, (_, color, text) => {
|
||||||
let carbonate = chalk;
|
let carbonate = chalk;
|
||||||
color.split('.').forEach(c => {
|
color.split('.').forEach(c => {
|
||||||
if (callPattern.test(c)) {
|
if (callPattern.test(c)) {
|
||||||
const args = JSON.parse(`[${ callPattern.exec(c)[1].replace(/'/g, '"') }]`);
|
const args = JSON.parse(`[${callPattern.exec(c)[1].replace(/'/g, '"')}]`);
|
||||||
c = /(\w+)/g.exec(c)[0];
|
c = /(\w+)/g.exec(c)[0];
|
||||||
carbonate = carbonate[c] ? carbonate[c].apply(carbonate[c], args) : carbonate;
|
carbonate = carbonate[c] ? carbonate[c].apply(carbonate[c], args) : carbonate;
|
||||||
} else {
|
} else {
|
||||||
carbonate = carbonate[c] || carbonate;
|
carbonate = carbonate[c] || carbonate;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
text = carbonate(text);
|
text = carbonate(text);
|
||||||
return tagPattern.test(text) ? parseTaggedString(text) : text;
|
return tagPattern.test(text) ? parseTaggedString(text) : text;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const applyOptions = (object, options = {}) => {
|
const applyOptions = (object, options = {}) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue