My app is dependent on the conversion of some HTML text elements into SVG elements, using Raphael.js.
The text in those HTML objects is given by the user, via a textarea input. Therefore, they can input new lines too. And those new lines need to be accounted for when creating the SVG. For this, I use the following code:
function replaceNL(text) {
return text.replace(/[\n\r]/g, "\n");
}
And when adding the SVG to the page:
var obj = paper.text(x,y,replaceNL(this.text));
The problem I've come across is that double (or more) line breaks strings (e.g. "\n\n") have the effect of just one in the .text()
method.
How can I overcome this?