INNER CODE UNIT · TypeScript
decodeHtmlEntities
RyanYipeng/SyncCaster · apps/extension/src/content-scripts/index.ts:459
function decodeHtmlEntities(text: string): string {
const textarea = document.createElement('textarea');
textarea.innerHTML = text;
return textarea.value;
}
function replaceFormulasWithPlaceholders(root: HTMLElement, formulaMap: Map<string, { tex: string; isDisplay: boolean }>): void {
const doc = root.ownerDocument || document;
const DS = String.fromCharCode(36);
root.querySelectorAll('[data-formula-id]').forEach((node) => {
const id = node.getAttribute('data-formula-id');
if (!id) return;
const formula = formulaMap.get(id);
if (!formula) return;
const wrapper = doc.createElement('span');
wrapper.setAttribute('data-sync-math', 'true');