INNER CODE UNIT · TypeScript

innerMatch

RyanYipeng/SyncCaster · apps/extension/src/content-scripts/index.ts:280

  const innerMatch = innerHTML.match(/<annotation[^>]*>([\s\S]*?)<\/annotation>/i);
  if (innerMatch && innerMatch[1]) {
    const tex = decodeHtmlEntities(innerMatch[1].trim());
    if (tex && /[a-zA-Z\\]/.test(tex)) {
      console.log('[math] Found LaTeX via innerHTML regex:', tex.substring(0, 80));
      return tex;
    }
  }
  
  // 方法5:遍历所有子元素查找 annotation(处理命名空间问题)
  const allElements = mathml.getElementsByTagName('*');
  for (let i = 0; i < allElements.length; i++) {
    const el = allElements[i];
    if (el.localName === 'annotation' || el.tagName.toLowerCase().endsWith(':annotation')) {
      const encoding = el.getAttribute('encoding') || '';
      if (encoding.includes('tex') || !encoding) {
        const tex = el.textContent?.trim();
        if (tex && tex.length > 0 && /[a-zA-Z\\{}_^]/.test(tex)) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…