For context, here is the expression I’m using.
txt = value;
n = effect("Height & Width")("Slider");
outStr = "";
newLine = ""
splt = txt.split(" ")
//convertBreak = thisComp.layer("Body Content").text.sourceText.replace(/"\r"/g,"§");
//convertBreak = thisComp.layer("Body Content").text.sourceText.split("\r").join("§");
for (i = 0; i < splt.length; i++){
if ((newLine + " " + splt[i]).length > n){
if (outStr != "") outStr += "\n";
outStr += newLine;
newLine = splt[i];
}else{
newLine += " " + splt[i];
}
}
if (newLine != ""){
if (outStr != "") outStr += "\n";
outStr += newLine;
}
outStr;
//REconvertBreak = thisComp.layer("Body Content").text.sourceText.replace("§",/"\r"/g);
//ReconvertBreak = thisComp.layer("Body Content").text.sourceText.split("§").join("\r");
You’ll notice some code is commented out — these were my (failed) attempts to find/replace carriage returns with a symbol, then run the code that determines where line breaks should go, then restore the symbols to carriage returns again.
I also tried replacing \r with \n in the original code to see if that’d resolve whatever conflict was occurring, but that had no effect either.