translation: skip translating pre, code and math tags, closes #1693 (#1698)

This commit is contained in:
Huang Xin
2025-07-28 15:18:19 +08:00
committed by GitHub
parent 23fa2dc8b2
commit b9add62ba7
3 changed files with 11 additions and 7 deletions
@@ -54,7 +54,7 @@ export function useTextTranslation(
if (!view || !enabled.current) return;
const observer = createTranslationObserver();
observerRef.current = observer;
const nodes = walkTextNodes(view);
const nodes = walkTextNodes(view, ['pre', 'code', 'math']);
console.log('Observing text nodes for translation:', nodes.length);
allTextNodes.current = nodes;
nodes.forEach((el) => observer.observe(el));