MCPcopy Create free account
hub / github.com/Bistutu/FluentRead / LLMStandardHTML

Function LLMStandardHTML

entrypoints/main/dom.ts:395–414  ·  view source on GitHub ↗
(node: any)

Source from the content-addressed store, hash-verified

393
394// 仅译文模式下获取 LLM 应当翻译的标准 HTML
395export function LLMStandardHTML(node: any) {
396 // 1. 初始化空字符串 text
397 // 2. 遍历子节点
398 // 3. 若为文本节点,拼接其文本内容
399 // 4. 若为元素节点且在 inlineSet 中,拼接其 outerHTML
400 // 5. 否则继续递归处理子节点
401 let text = "";
402 node.childNodes.forEach((child: any) => {
403 if (child.nodeType === Node.TEXT_NODE) {
404 text += child.nodeValue;
405 } else if (child.nodeType === Node.ELEMENT_NODE) {
406 if (inlineSet.has(child.tagName.toLowerCase())) {
407 text += child.outerHTML;
408 } else {
409 text += LLMStandardHTML(child);
410 }
411 }
412 });
413 return text;
414}
415
416export function beautyHTML(text: string): string {
417 // 1. 先替换 SVG 中的大小写敏感词

Callers 1

singleTranslateFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected