INNER CODE UNIT · TypeScript
fallbackMatch
RyanYipeng/SyncCaster · apps/extension/src/content-scripts/index.ts:236
const fallbackMatch = serialized.match(/<(?:m:)?annotation[^>]*>([\s\S]*?)<\/(?:m:)?annotation>/i);
if (fallbackMatch && fallbackMatch[1]) {
const tex = decodeHtmlEntities(fallbackMatch[1].trim());
if (tex && /[a-zA-Z\\{}_^]/.test(tex)) {
console.log('[math] Found LaTeX via XMLSerializer fallback:', tex.substring(0, 80));
return tex;
}
}
} catch (e) {
console.log('[math] XMLSerializer failed:', e);
}
// 方法2:直接从 annotation 元素获取
const annotationSelectors = [
'annotation[encoding="application/x-tex"]',
'annotation',
];