MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / cleanXmlContent

Function cleanXmlContent

packages/node-runtime/src/ai/preprocessor/pipeline.ts:99–110  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

97const XML_START = /^<\?xml\s|^<msg[\s>]/
98
99function cleanXmlContent(content: string): string {
100 const trimmed = content.trim()
101 if (!XML_START.test(trimmed)) return content
102
103 const title = extractXmlTag(trimmed, 'title')
104 const des = extractXmlTag(trimmed, 'des')
105
106 if (title) {
107 return des ? `[分享] ${title} - ${des}` : `[分享] ${title}`
108 }
109 return '[应用消息]'
110}
111
112function extractXmlTag(xml: string, tag: string): string | null {
113 const openTag = `<${tag}>`

Callers 1

applyDataCleaningFunction · 0.85

Calls 1

extractXmlTagFunction · 0.85

Tested by

no test coverage detected