Improved invisible white-space injection.
This commit is contained in:
parent
3f0af3a519
commit
499c0aa555
|
|
@ -53,11 +53,23 @@ class chatPreprocessor{
|
||||||
|
|
||||||
addWhitespace(){
|
addWhitespace(){
|
||||||
//for each word object in the body
|
//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 the word object hasn't been pre-processed elsewhere
|
||||||
if(wordObj.type == "word"){
|
if(wordObj.type == "word"){
|
||||||
|
var wordArray = [];
|
||||||
//Add invisible whitespace in-between characters to keep it from breaking page layout
|
//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("");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue