Improved invisible white-space injection.

This commit is contained in:
rainbow napkin 2024-12-05 05:56:36 -05:00
parent 3f0af3a519
commit 499c0aa555

View file

@ -53,11 +53,23 @@ class chatPreprocessor{
addWhitespace(){
//for each word object in the body
this.bodyArray.forEach((wordObj, index) => {
this.bodyArray.forEach((wordObj, wordIndex) => {
//if the word object hasn't been pre-processed elsewhere
if(wordObj.type == "word"){
var wordArray = [];
//Add invisible whitespace in-between characters to keep it from breaking page layout
this.bodyArray[index].string = wordObj.string.split("").join("");
//this.bodyArray[index].string = wordObj.string.split("").join("");
this.bodyArray[wordIndex].string.split("").forEach((char, charIndex) => {
wordArray.push(char);
//Every eight characters
if(charIndex != 0 && charIndex % 8 == 0){
//Push an invisible line-break character
wordArray.push("");
}
});
this.bodyArray[wordIndex].string = wordArray.join("");
}
});
}