escapeForHtmlEmbed static method

String escapeForHtmlEmbed(
  1. String s
)

Implementation

static String escapeForHtmlEmbed(String s)
{
  // https://stackoverflow.com/questions/39193510/how-to-insert-arbitrary-json-in-htmls-script-tag
  return s
    .replaceAll(r"<", r"\u003c")
    .replaceAll(r">", r"\u003e")
    .replaceAll(r"&", r"\u0026")
    .replaceAll(r"'", r"\u0027");
}