public static String escapeHTML(String text, boolean makeSpacesNonBreaking) {

		StringBuilder buffer = new StringBuilder(text.length());
		text.codePoints().forEach(cp -> {
			switch (cp) {
				case ' ':
					buffer.append(makeSpacesNonBreaking ? HTML_SPACE : " ");
					break;
				case '&':
					buffer.append("&amp;");
					break;
				case '<':
					buffer.append("&lt;");
					break;
				case '>':
					buffer.append("&gt;");
					break;
				default:
					if (charNeedsHTMLEscaping(cp)) {
						buffer.append("&#x");
						buffer.append(Integer.toString(cp, 16).toUpperCase());
						buffer.append(";");
					}
					else {
						buffer.appendCodePoint(cp);
					}
					break;
			}
		});

		return buffer.toString();
	}
Escapes any HTML special characters in the specified text.
<p>
Does not otherwise modify the input text or wrap lines.
<p>
Calling this twice will result in text being double-escaped, which will not display correctly.
<p>
See also <code>StringEscapeUtils#escapeHtml3(String)</code> if you need quote-safe html encoding.

@param text plain-text that might have some characters that should NOT be interpreted as HTML
@param makeSpacesNonBreaking true to convert spaces into {@value #HTML_SPACE}
@return string with any html characters replaced with equivalents
Ghidra/Framework/Gui/src/main/java/ghidra/util/HTMLUtilities.java