siyuan/app/src/util/escape.ts

7 lines
226 B
TypeScript

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