htmlEscapePreservingNewlinesAndSpaces static method

String htmlEscapePreservingNewlinesAndSpaces(
  1. String textOrHtml
)

Returns HTML-escaped text as a SafeHtml object, with newlines changed to <br> and escaping whitespace to preserve spatial formatting. Character entity #160 is used to make it safer for XML. @param {!goog.html.SafeHtml.TextOrHtml_} textOrHtml The text to escape. If the parameter is of type SafeHtml it is returned directly (no escaping is done). @return {!goog.html.SafeHtml} The escaped text, wrapped as a SafeHtml.

Implementation

static String htmlEscapePreservingNewlinesAndSpaces(String textOrHtml)
{
  String html = htmlEscape(textOrHtml);
  return whitespaceEscape(html);
}