Skip to content

Commit d05a706

Browse files
committed
lint fix - fix multiline strings for wordlists
1 parent 9e24cde commit d05a706

2 files changed

Lines changed: 33 additions & 4 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,4 @@ examples/gemini_response.txt
185185
# AAC Metrics benchmarking data
186186
aac-metrics/
187187
compare-effort-scores.ts
188+
.DS_Store

src/processors/gridsetProcessor.ts

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,8 @@ class GridsetProcessor extends BaseProcessor {
378378
if (typeof val === 'number') return String(val);
379379

380380
if (typeof val === 'object') {
381-
if ('#text' in val) return String(val['#text']);
381+
// Don't immediately return #text - it might be whitespace alongside structured content
382+
// Process structured format first: <p><s><r>text</r></s></p>
382383

383384
// Handle Grid3 structured format <p><s><r>text</r></s></p>
384385
// Can start at p, s, or r level
@@ -394,8 +395,15 @@ class GridsetProcessor extends BaseProcessor {
394395
}
395396
continue;
396397
}
397-
if (typeof r === 'object' && r !== null && '#text' in r) {
398-
parts.push(String(r['#text']));
398+
if (typeof r === 'object' && r !== null) {
399+
// Check for #text (regular text) or #cdata (CDATA sections)
400+
if ('#text' in r) {
401+
parts.push(String(r['#text']));
402+
} else if ('#cdata' in r) {
403+
parts.push(String(r['#cdata']));
404+
} else {
405+
parts.push(String(r));
406+
}
399407
} else {
400408
parts.push(String(r));
401409
}
@@ -448,7 +456,15 @@ class GridsetProcessor extends BaseProcessor {
448456
}
449457
const password = this.getGridsetPassword(filePathOrBuffer);
450458
const entries = getZipEntriesFromAdapter(zipResult.zip, password);
451-
const parser = new XMLParser({ ignoreAttributes: false });
459+
const options = {
460+
ignoreAttributes: false,
461+
ignoreDeclaration: true,
462+
parseTagValue: false,
463+
trimValues: false,
464+
textNodeName: '#text',
465+
cdataProp: '#cdata',
466+
};
467+
const parser = new XMLParser(options);
452468
const isEncryptedArchive =
453469
typeof filePathOrBuffer === 'string' && filePathOrBuffer.toLowerCase().endsWith('.gridsetx');
454470
const encryptedContentPassword = this.getGridsetPassword(filePathOrBuffer);
@@ -722,6 +738,18 @@ class GridsetProcessor extends BaseProcessor {
722738
if (text) {
723739
const val = this.textOf(text);
724740
if (val) {
741+
// Debug: log WordList items with spaces to check extraction
742+
if (pageWordListItems.length < 3) {
743+
console.log(
744+
`[WordList] Extracted text: "${val}" (length: ${val.length}, has spaces: ${val.includes(' ')})`
745+
);
746+
console.log(
747+
`[WordList] Chars:`,
748+
Array.from(val)
749+
.map((c) => `"${c}" (${c.charCodeAt(0)})`)
750+
.join(', ')
751+
);
752+
}
725753
pageWordListItems.push({
726754
text: val,
727755
image: item.Image || item.image || undefined,

0 commit comments

Comments
 (0)