siyuan/app/src/util/escape.ts

11 lines
316 B
TypeScript

export const escapeHtml = (html: string) => {
return html.replace(/&/g, "&amp;").replace(/</g, "&lt;");
};
export const escapeGreat = (html: string) => {
return html.replace(/</g, "&lt;");
};
export const escapeAttr = (html: string) => {
return html.replace(/"/g, "&quot;").replace(/'/g, "&apos;");
};