chore: sigh

This commit is contained in:
Severian
2025-02-13 14:40:10 +08:00
parent 87cef3ac20
commit b6dcc131d3

View File

@@ -39,25 +39,32 @@ interface PersonaMatch {
} }
function findTagsBetween(content: string, startMarker: string, endMarker: string): PersonaMatch[] { function findTagsBetween(content: string, startMarker: string, endMarker: string): PersonaMatch[] {
const startIdx = content.indexOf(`<${startMarker}>`); const startMarkerTag = `<${startMarker}>`;
const endMarkerTag = `<${endMarker}>`;
const startIdx = content.indexOf(startMarkerTag);
if (startIdx === -1) return []; if (startIdx === -1) return [];
const endIdx = content.indexOf(`<${endMarker}>`); const endIdx = content.indexOf(endMarkerTag);
if (endIdx === -1) return []; if (endIdx === -1) return [];
const section = content.slice(startIdx + startMarker.length + 2, endIdx); const section = content.slice(startIdx, endIdx);
console.log("Section found:", section);
const matches: PersonaMatch[] = []; const matches: PersonaMatch[] = [];
const tagPattern = /<([^/>][^>]*)>([^]*?)<\/\1>/g; const tagPattern = /<([^/>\s][^>]*)>([^]*?)<\/\1>/g;
let match; let match;
while ((match = tagPattern.exec(section)) !== null) { while ((match = tagPattern.exec(section)) !== null) {
console.log("Found match:", match[1], match[2].substring(0, 50) + "...");
matches.push({ matches.push({
tag: match[1], tag: match[1].trim(),
content: match[2].trim() content: match[2].trim()
}); });
} }
console.log("Total matches found:", matches.length);
return matches; return matches;
} }