@@ -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