function escapeHtml(text) {
	const map = {
		'&': '&amp;',
		'<': '&lt;',
		'>': '&gt;',
		'"': '&quot;',
		"'": '&#039;',
	};
	return text.replace(/[&<>"']/g, function(m) {
		return map[m];
	});
}
Escapes HTML special characters to prevent XSS attacks.

@param {string} text - The text to escape.
@returns {string} - The escaped text.