core/formatters/markup.formatter.ts
core/formatters/markup.formatter.ts is a file in GovLab Patterns. 17 lines of code and 4 definitions.
const XML_ESCAPES: ReadonlyMap<string, string> = new Map([
["&", "&"],
["<", "<"],
[">", ">"],
['"', """],
["'", "'"],
]);
export const escapeXml = function escapeXml(value: string): string {
let out = "";
for (const ch of value) {
out += XML_ESCAPES.get(ch) ?? ch;
}
return out;
};
export const anchorMarkup = function anchorMarkup(href: string, label: string): string {
return `<a href="${href}">${label}</a>`;
};