diff --git a/apps/server/src/lib/xml-extractor.ts b/apps/server/src/lib/xml-extractor.ts index 26e51bc3..49dbc368 100644 --- a/apps/server/src/lib/xml-extractor.ts +++ b/apps/server/src/lib/xml-extractor.ts @@ -110,7 +110,7 @@ export function extractXmlElements( const log = options.logger || logger; const values: string[] = []; - const regex = new RegExp(`<${tagName}>(.*?)<\\/${tagName}>`, 'g'); + const regex = new RegExp(`<${tagName}>([\\s\\S]*?)<\\/${tagName}>`, 'g'); const matches = xmlContent.matchAll(regex); for (const match of matches) { @@ -151,11 +151,11 @@ export function extractImplementedFeatures( const featureContent = featureMatch[1]; // Extract name - const nameMatch = featureContent.match(/(.*?)<\/name>/); + const nameMatch = featureContent.match(/([\s\S]*?)<\/name>/); const name = nameMatch ? unescapeXml(nameMatch[1].trim()) : ''; // Extract description - const descMatch = featureContent.match(/(.*?)<\/description>/); + const descMatch = featureContent.match(/([\s\S]*?)<\/description>/); const description = descMatch ? unescapeXml(descMatch[1].trim()) : ''; // Extract file_locations if present @@ -200,10 +200,9 @@ export function extractImplementedFeatureNames( * @returns XML string for the feature */ export function featureToXml(feature: ImplementedFeature, indent: string = ' '): string { - const i1 = indent; - const i2 = indent + indent; - const i3 = indent + indent + indent; - const i4 = indent + indent + indent + indent; + const i2 = indent.repeat(2); + const i3 = indent.repeat(3); + const i4 = indent.repeat(4); let xml = `${i2} ${i3}${escapeXml(feature.name)} diff --git a/apps/server/tests/unit/lib/xml-extractor.test.ts b/apps/server/tests/unit/lib/xml-extractor.test.ts index 00829990..750a5f33 100644 --- a/apps/server/tests/unit/lib/xml-extractor.test.ts +++ b/apps/server/tests/unit/lib/xml-extractor.test.ts @@ -702,10 +702,11 @@ describe('xml-extractor.ts', () => { second `; - // Note: multiline content in single element may not be captured due to . not matching newlines + // Multiline content is now captured with [\s\S]*? pattern const result = extractXmlElements(xml, 'item'); - expect(result).toHaveLength(1); // Only matches single-line content - expect(result[0]).toBe('second'); + expect(result).toHaveLength(2); + expect(result[0]).toBe('first'); + expect(result[1]).toBe('second'); }); it('should handle consecutive elements without whitespace', () => {