Corrected invisible whitespace on chromium-based browsers for line-breaks in long words.
This commit is contained in:
parent
49684b32a1
commit
9f52d13bde
2 changed files with 6 additions and 6 deletions
|
|
@ -144,7 +144,7 @@ class chatPostprocessor{
|
||||||
//with negative lookaheads to exclude file seperators so we don't split link placeholders, dashes so we dont split usernames and other things, and accented characters to keep those from splitting boundries too
|
//with negative lookaheads to exclude file seperators so we don't split link placeholders, dashes so we dont split usernames and other things, and accented characters to keep those from splitting boundries too
|
||||||
//Also split by any invisble whitespace as a crutch to handle mushed links/emotes
|
//Also split by any invisble whitespace as a crutch to handle mushed links/emotes
|
||||||
//If we can one day figure out how to split non-repeating special chars instead of special chars with whitespace, that would be perf, unfortunately my brain hasn't rotted enough to understand regex like that just yet.
|
//If we can one day figure out how to split non-repeating special chars instead of special chars with whitespace, that would be perf, unfortunately my brain hasn't rotted enough to understand regex like that just yet.
|
||||||
const splitString = utils.unescapeEntities(this.rawData.msg).split(/(?<!-)(?<!␜)(?=\w)\b|(?!-|[\u00C0-\u017F])(?<=\w)\b|(?=\s)\B|(?<=\s)\B|ㅤ/g);
|
const splitString = utils.unescapeEntities(this.rawData.msg).split(/(?<!-)(?<!␜)(?=\w)\b|(?!-|[\u00C0-\u017F])(?<=\w)\b|(?=\s)\B|(?<=\s)\B|/g);
|
||||||
|
|
||||||
//for each word in the splitstring
|
//for each word in the splitstring
|
||||||
splitString.forEach((string) => {
|
splitString.forEach((string) => {
|
||||||
|
|
@ -474,7 +474,7 @@ class chatPostprocessor{
|
||||||
//After eight characters
|
//After eight characters
|
||||||
if(charIndex > 8){
|
if(charIndex > 8){
|
||||||
//Push an invisible line-break character between every character
|
//Push an invisible line-break character between every character
|
||||||
wordArray.push("ㅤ");
|
wordArray.push("");
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -116,14 +116,14 @@ class commandPreprocessor{
|
||||||
*/
|
*/
|
||||||
processEmotes(){
|
processEmotes(){
|
||||||
//inject invisible whitespace in-between emotes to prevent from mushing links together
|
//inject invisible whitespace in-between emotes to prevent from mushing links together
|
||||||
this.message = this.message.replaceAll('][',']ㅤ[');
|
this.message = this.message.replaceAll('][','][');
|
||||||
|
|
||||||
//For each list of emotes
|
//For each list of emotes
|
||||||
Object.keys(this.emotes).forEach((key) => {
|
Object.keys(this.emotes).forEach((key) => {
|
||||||
//For each emote in the current list
|
//For each emote in the current list
|
||||||
this.emotes[key].forEach((emote) => {
|
this.emotes[key].forEach((emote) => {
|
||||||
//Inject emote links into the message, pad with invisible whitespace to keep link from getting mushed
|
//Inject emote links into the message, pad with invisible whitespace to keep link from getting mushed
|
||||||
this.message = this.message.replaceAll(`[${emote.name}]`, `ㅤ${emote.link}ㅤ`);
|
this.message = this.message.replaceAll(`[${emote.name}]`, `${emote.link}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -135,13 +135,13 @@ class commandPreprocessor{
|
||||||
//Strip out file seperators in-case the user is being a smart-ass
|
//Strip out file seperators in-case the user is being a smart-ass
|
||||||
this.message = this.message.replaceAll('␜','');
|
this.message = this.message.replaceAll('␜','');
|
||||||
//Split message by links
|
//Split message by links
|
||||||
var splitMessage = this.message.split(/(https?:\/\/[^\sㅤ]+)/g);
|
var splitMessage = this.message.split(/(https?:\/\/[^\s]+)/g);
|
||||||
//Create an empty array to hold links
|
//Create an empty array to hold links
|
||||||
this.links = [];
|
this.links = [];
|
||||||
|
|
||||||
splitMessage.forEach((chunk, chunkIndex) => {
|
splitMessage.forEach((chunk, chunkIndex) => {
|
||||||
//For each chunk that is a link
|
//For each chunk that is a link
|
||||||
if(chunk.match(/(https?:\/\/[^\sㅤ]+)/g)){
|
if(chunk.match(/(https?:\/\/[^\s]+)/g)){
|
||||||
//I looked online for obscure characters that no one would use to prevent people from chatting embed placeholders
|
//I looked online for obscure characters that no one would use to prevent people from chatting embed placeholders
|
||||||
//Then I found this fucker, turns out it's literally made for the job lmao (even if it was originally intended for paper/magnetic tape)
|
//Then I found this fucker, turns out it's literally made for the job lmao (even if it was originally intended for paper/magnetic tape)
|
||||||
//Replace link with indexed placeholder
|
//Replace link with indexed placeholder
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue