mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-04 09:13:08 +00:00
fix: adress pr comments
This commit is contained in:
@@ -110,7 +110,7 @@ export function extractXmlElements(
|
|||||||
const log = options.logger || logger;
|
const log = options.logger || logger;
|
||||||
const values: string[] = [];
|
const values: string[] = [];
|
||||||
|
|
||||||
const regex = new RegExp(`<${tagName}>(.*?)<\\/${tagName}>`, 'g');
|
const regex = new RegExp(`<${tagName}>([\\s\\S]*?)<\\/${tagName}>`, 'g');
|
||||||
const matches = xmlContent.matchAll(regex);
|
const matches = xmlContent.matchAll(regex);
|
||||||
|
|
||||||
for (const match of matches) {
|
for (const match of matches) {
|
||||||
@@ -151,11 +151,11 @@ export function extractImplementedFeatures(
|
|||||||
const featureContent = featureMatch[1];
|
const featureContent = featureMatch[1];
|
||||||
|
|
||||||
// Extract name
|
// Extract name
|
||||||
const nameMatch = featureContent.match(/<name>(.*?)<\/name>/);
|
const nameMatch = featureContent.match(/<name>([\s\S]*?)<\/name>/);
|
||||||
const name = nameMatch ? unescapeXml(nameMatch[1].trim()) : '';
|
const name = nameMatch ? unescapeXml(nameMatch[1].trim()) : '';
|
||||||
|
|
||||||
// Extract description
|
// Extract description
|
||||||
const descMatch = featureContent.match(/<description>(.*?)<\/description>/);
|
const descMatch = featureContent.match(/<description>([\s\S]*?)<\/description>/);
|
||||||
const description = descMatch ? unescapeXml(descMatch[1].trim()) : '';
|
const description = descMatch ? unescapeXml(descMatch[1].trim()) : '';
|
||||||
|
|
||||||
// Extract file_locations if present
|
// Extract file_locations if present
|
||||||
@@ -200,10 +200,9 @@ export function extractImplementedFeatureNames(
|
|||||||
* @returns XML string for the feature
|
* @returns XML string for the feature
|
||||||
*/
|
*/
|
||||||
export function featureToXml(feature: ImplementedFeature, indent: string = ' '): string {
|
export function featureToXml(feature: ImplementedFeature, indent: string = ' '): string {
|
||||||
const i1 = indent;
|
const i2 = indent.repeat(2);
|
||||||
const i2 = indent + indent;
|
const i3 = indent.repeat(3);
|
||||||
const i3 = indent + indent + indent;
|
const i4 = indent.repeat(4);
|
||||||
const i4 = indent + indent + indent + indent;
|
|
||||||
|
|
||||||
let xml = `${i2}<feature>
|
let xml = `${i2}<feature>
|
||||||
${i3}<name>${escapeXml(feature.name)}</name>
|
${i3}<name>${escapeXml(feature.name)}</name>
|
||||||
|
|||||||
@@ -702,10 +702,11 @@ describe('xml-extractor.ts', () => {
|
|||||||
</item>
|
</item>
|
||||||
<item>second</item>
|
<item>second</item>
|
||||||
</items>`;
|
</items>`;
|
||||||
// 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');
|
const result = extractXmlElements(xml, 'item');
|
||||||
expect(result).toHaveLength(1); // Only matches single-line content
|
expect(result).toHaveLength(2);
|
||||||
expect(result[0]).toBe('second');
|
expect(result[0]).toBe('first');
|
||||||
|
expect(result[1]).toBe('second');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle consecutive elements without whitespace', () => {
|
it('should handle consecutive elements without whitespace', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user