MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / stripLineNumbers

Function stripLineNumbers

src/integrations/misc/extract-text.ts:177–200  ·  view source on GitHub ↗
(content: string, aggressive: boolean = false)

Source from the content-addressed store, hash-verified

175 * @returns The content with line numbers removed
176 */
177export function stripLineNumbers(content: string, aggressive: boolean = false): string {
178 // Split into lines to handle each line individually
179 const lines = content.split(/\r?\n/)
180
181 // Process each line
182 const processedLines = lines.map((line) => {
183 // Match line number pattern and capture everything after the pipe
184 const match = aggressive ? line.match(/^\s*(?:\d+\s)?\|\s(.*)$/) : line.match(/^\s*\d+\s+\|(?!\|)\s?(.*)$/)
185 return match ? match[1] : line
186 })
187
188 // Join back with original line endings (carriage return (\r) + line feed (\n) or just line feed (\n))
189 const lineEnding = content.includes("\r\n") ? "\r\n" : "\n"
190 let result = processedLines.join(lineEnding)
191
192 // Preserve trailing newline if present in original content
193 if (content.endsWith(lineEnding)) {
194 if (!result.endsWith(lineEnding)) {
195 result += lineEnding
196 }
197 }
198
199 return result
200}
201
202/**
203 * Truncates multi-line output while preserving context from both the beginning and end.

Callers 4

executeMethod · 0.90
handlePartialMethod · 0.90
applyDiffMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected