INNER CODE UNIT · TypeScript
extractMathJaxAnnotation
RyanYipeng/SyncCaster · apps/extension/src/content-scripts/index.ts:168
function extractMathJaxAnnotation(node: Element): string {
const annotation = node.querySelector('annotation[encoding*="tex"]');
if (annotation?.textContent) return annotation.textContent.trim();
// 尝试从 outerHTML 提取
const html = node.outerHTML || '';
const match = html.match(/<annotation[^>]*encoding=["'][^"']*tex[^"']*["'][^>]*>([\s\S]*?)<\/annotation>/i);
if (match?.[1]) return match[1].trim();
return '';
}
/**
* 修复知乎列表结构
* 知乎的列表可能有非标准的嵌套结构,需要修复以确保正确转换为 Markdown
*/
function fixZhihuListStructure(container: HTMLElement): void {
// 知乎可能将嵌套列表放在 li 外面,需要修复