@@ -32,6 +32,7 @@ type BookCollection = {
3232 section : string ; // Pentateuch
3333 chapters : number ;
3434 chaptersN : string ; // 1-34
35+ fonts : string [ ] ;
3536 file : string ;
3637 audio : BookCollectionAudio [ ] ;
3738 styles ?: {
@@ -50,6 +51,7 @@ type BookCollection = {
5051 numeralSystem : string ;
5152 verseNumbers : string ;
5253 } ;
54+ fonts : string [ ] ;
5355 languageCode : string ;
5456 languageName ?: string ;
5557 footer ?: HTML ; //
@@ -441,13 +443,20 @@ function convertConfig(dataDir: string, verbose: number) {
441443 }
442444 const bkStyles = book . querySelector ( 'styles' ) ;
443445 const styles = bkStyles ? parseStyles ( bkStyles , verbose ) : undefined ;
446+ const fontChoiceTag = book . querySelector ( 'font-choice' ) ;
447+ const fonts = fontChoiceTag
448+ ? Array . from ( fontChoiceTag . getElementsByTagName ( 'font-choice-family' ) ) . map (
449+ ( x ) => x . innerHTML
450+ )
451+ : [ ] ;
444452
445453 books . push ( {
446454 chapters : parseInt (
447455 book . getElementsByTagName ( 'ct' ) [ 0 ] . attributes . getNamedItem ( 'c' ) ! . value
448456 ) ,
449457 chaptersN : book . getElementsByTagName ( 'cn' ) [ 0 ] . attributes . getNamedItem ( 'value' ) !
450458 . value ,
459+ fonts,
451460 id : book . attributes . getNamedItem ( 'id' ) ! . value ,
452461 type : book . attributes . getNamedItem ( 'type' ) ?. value ,
453462 name : book . getElementsByTagName ( 'n' ) [ 0 ] ?. innerHTML ,
@@ -465,12 +474,16 @@ function convertConfig(dataDir: string, verbose: number) {
465474 ? collectionNameTags [ 0 ] . innerHTML
466475 : undefined ;
467476 if ( verbose >= 2 ) console . log ( `.. collectionName: ` , collectionName ) ;
468- data . traits [ 'has-glossary' ] =
469- data . bookCollections . filter (
470- ( bc ) => bc . books . filter ( ( b ) => b . type === 'glossary' ) . length > 0
471- ) . length > 0 ;
472477 const stylesTag = tag . getElementsByTagName ( 'styles-info' ) [ 0 ] ;
473478 if ( verbose >= 3 ) console . log ( `.... styles: ` , JSON . stringify ( stylesTag ) ) ;
479+ const fontChoiceTag = tag . getElementsByTagName ( 'font-choice' ) [ 0 ] ;
480+ if ( verbose >= 3 ) console . log ( `.... fontChoice: ` , JSON . stringify ( fontChoiceTag ) ) ;
481+ const fonts = fontChoiceTag
482+ ? Array . from ( fontChoiceTag . getElementsByTagName ( 'font-choice-family' ) ) . map (
483+ ( x ) => x . innerHTML
484+ )
485+ : [ ] ;
486+
474487 const writingSystem = tag . getElementsByTagName ( 'writing-system' ) [ 0 ] ;
475488 if ( verbose >= 3 ) console . log ( `.... writingSystem: ` , JSON . stringify ( writingSystem ) ) ;
476489 if ( ! writingSystem ) {
@@ -509,6 +522,7 @@ function convertConfig(dataDir: string, verbose: number) {
509522 collectionDescription,
510523 features,
511524 books,
525+ fonts,
512526 languageCode,
513527 languageName,
514528 footer,
@@ -539,6 +553,11 @@ function convertConfig(dataDir: string, verbose: number) {
539553 } ) ;
540554 if ( verbose >= 3 ) console . log ( `.... collection: ` , JSON . stringify ( data . bookCollections [ 0 ] ) ) ;
541555 }
556+ // After all the book collections have been parsed, we can determine some traits
557+ data . traits [ 'has-glossary' ] =
558+ data . bookCollections . filter (
559+ ( bc ) => bc . books . filter ( ( b ) => b . type === 'glossary' ) . length > 0
560+ ) . length > 0 ;
542561 if ( verbose )
543562 console . log (
544563 `Converted ${ data . bookCollections . length } book collections with [${ data . bookCollections
0 commit comments