emoticons

main
Haoming 2025-04-25 11:02:16 +08:00
parent c3c8cfb4d2
commit 0c90817db4
1 changed files with 19 additions and 0 deletions

View File

@ -68,12 +68,29 @@ class LeFormatter {
return tags;
}
/** @param {string} input @returns {string} */
static #toExpression(input) {
return input
.replace(/[,\n]\s*> <\s*[,\n]/g, ", $SHY$,")
.replace(/[,\n]\s*:3\s*[,\n]/g, ", $CAT$,");
}
/** @param {string} input @returns {string} */
static #fromExpression(input) {
return input
.replace("$SHY$", "> <")
.replace("$CAT$", ":3");
}
/** @param {string} input @param {boolean} dedupe @param {boolean} removeUnderscore @returns {string} */
static formatString(input, dedupe, removeUnderscore) {
// Remove Underscore
input = removeUnderscore ? this.#removeUnderscore(input) : input;
// Special Tags
input = this.#toExpression(input);
// Fix Commas inside Brackets
input = input
.replace(/,+\s*\)/g, '),')
@ -128,6 +145,8 @@ class LeFormatter {
// Remove empty before Colon
input = input.replace(/\,\s*\:(\d)/g, ':$1');
input = this.#fromExpression(input);
return input;
}