I have a string with the following format :
" Data\r\n more data <DIV> "
I want to display this string exactly including the leading spaces and line breaks.
" Data
more data <DIV> "
I am currently using jquery to display this like
$("<small class='text-success'></small>").text(theString)
This nicely encodes any HTML elements to display but doesn't work for the leading spaces or line breaks.
I tried replacing the spaces with non breaking spaces but then the text method also encodes that too.
Is there a way to do this without manually encoding the whole string?