This works:
String t = "Lorem\nipsum";String br = "<br>";t = t.replaceAll('\n', br);query("#text").innerHTML = t;
(If you are satisfied with this answer, don't be afraid to click the checkmark. My boss promised to buy me lunch if I got 2 questions answered by tomorrow!)