jstd-web/node_modules/diagram-js/lib/util/EscapeUtil.js

24 lines
375 B
JavaScript
Raw Normal View History

2025-11-25 15:23:22 +08:00
/**
* @param {string} str
* @returns {string}
*/
export function escapeCSS(str) {
return CSS.escape(str);
}
var HTML_ESCAPE_MAP = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
'\'': '&#39;'
};
export function escapeHTML(str) {
str = '' + str;
return str && str.replace(/[&<>"']/g, function(match) {
return HTML_ESCAPE_MAP[match];
});
}