MCPcopy Create free account
hub / github.com/enowdev/enowX-Coder / cleanContent

Function cleanContent

src/components/chat/ChatMessage.tsx:16–38  ·  view source on GitHub ↗
(raw: string)

Source from the content-addressed store, hash-verified

14 * heading-based segment markers so we render a single clean markdown block.
15 */
16const cleanContent = (raw: string): string => {
17 let text = raw.replace(/\r\n/g, '\n').trim();
18
19 // Remove XML segment wrappers — keep inner content
20 text = text.replace(/<\/?(?:thinking|tool|response)>/gi, '');
21
22 // Remove heading lines that are purely segment labels
23 text = text.replace(
24 /^#{1,6}\s+(?:thinking|reasoning|analysis|chain of thought|tool execution?|response|final answer|answer)\s*$/gim,
25 '',
26 );
27
28 // Remove prefix-style segment labels (e.g. "Response: ...")
29 text = text.replace(
30 /^(?:thinking|reasoning|analysis|tool|executing tool|response|final answer)\s*[:\-]\s*/gim,
31 '',
32 );
33
34 // Collapse 3+ consecutive blank lines into 2
35 text = text.replace(/\n{3,}/g, '\n\n');
36
37 return text.trim();
38};
39
40const markdownComponents = {
41 code: MarkdownCodeBlock as React.ComponentType<React.HTMLAttributes<HTMLElement>>,

Callers 1

ChatMessage.tsxFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected