Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

609 B
Raw Blame
/** The HTML entities models write in place of characters, and the characters. */
export const HTML_ENTITIES: Readonly<Record<string, string>> = {
  '&amp;': '&',
  '&nbsp;': ' ',
  '&lt;': '<',
  '&gt;': '>',
  '&quot;': '"',
  '&copy;': '©',
  '&reg;': '®',
  '&trade;': '™',
};

const ENTITY = new RegExp(Object.keys(HTML_ENTITIES).join('|'), 'gi');

/** `text` with each entity read once as its character, so `&amp;lt;` stays `&lt;`. */
export function decodeHtmlEntities(text: string): string {
  return text.replace(
    ENTITY,
    (entity) => HTML_ENTITIES[entity.toLowerCase()] ?? entity
  );
}