@@ -10,6 +10,7 @@ import { queries, postQueries, freeze } from '../sab-proskomma-tools';
10
10
import { convertMarkdownsToMilestones } from './convertMarkdown' ;
11
11
import { verifyGlossaryEntries } from './verifyGlossaryEntries' ;
12
12
import { hasAudioExtension , hasImageExtension } from './stringUtils' ;
13
+ import { convertStorybookElements } from './storybook' ;
13
14
14
15
/**
15
16
* Loops through bookCollections property of configData.
@@ -22,10 +23,6 @@ function replaceVideoTags(text: string, _bcId: string, _bookId: string): string
22
23
return text . replace ( / \\ v i d e o ( .* ) / g, '\\zvideo-s |id="$1"\\*\\zvideo-e\\*' ) ;
23
24
}
24
25
25
- // This is the start of supporting story books, but it still fails if there is no chapter.
26
- function replacePageTags ( text : string , _bcId : string , _bookId : string ) : string {
27
- return text . replace ( / \\ p a g e ( .* ) / g, '\\zpage-s |id="$1"\\*\\zpage-e\\*' ) ;
28
- }
29
26
function loadGlossary ( collection : any , dataDir : string ) : string [ ] {
30
27
const glossary : string [ ] = [ ] ;
31
28
for ( const book of collection . books ) {
@@ -101,16 +98,21 @@ function isImageMissing(imageSource: string): boolean {
101
98
const filterFunctions : ( ( text : string , bcId : string , bookId : string ) => string ) [ ] = [
102
99
removeStrongNumberReferences ,
103
100
replaceVideoTags ,
104
- replacePageTags ,
105
101
convertMarkdownsToMilestones ,
106
102
removeMissingFigures
107
103
] ;
108
104
109
- function applyFilters ( text : string , bcId : string , bookId : string ) : string {
105
+ function applyFilters ( text : string , bcId : string , bookId : string , bookType ?: string ) : string {
110
106
let filteredText = text ;
111
107
for ( const filterFn of filterFunctions ) {
112
108
filteredText = filterFn ( filteredText , bcId , bookId ) ;
113
109
}
110
+ if ( bookType === 'story' ) {
111
+ filteredText = convertStorybookElements ( filteredText ) ;
112
+ }
113
+ if ( bcId == 'C01' && bookId == '1' ) {
114
+ console . log ( filteredText . slice ( 0 , 1000 ) ) ;
115
+ }
114
116
return filteredText ;
115
117
}
116
118
@@ -204,7 +206,6 @@ export async function convertBooks(
204
206
for ( const book of collection . books ) {
205
207
let bookConverted = false ;
206
208
switch ( book . type ) {
207
- case 'story' :
208
209
case 'songs' :
209
210
case 'audio-only' :
210
211
case 'bloom-player' :
@@ -490,7 +491,7 @@ function convertScriptureBook(
490
491
function processBookContent ( resolve : ( ) => void , err : any , content : string ) {
491
492
//process.stdout.write(`processBookContent: bookId:${book.id}, error:${err}\n`);
492
493
if ( err ) throw err ;
493
- content = applyFilters ( content , context . bcId , book . id ) ;
494
+ content = applyFilters ( content , context . bcId , book . id , book . type ) ;
494
495
if ( context . configData . traits [ 'has-glossary' ] ) {
495
496
content = verifyGlossaryEntries ( content , bcGlossary ) ;
496
497
}
0 commit comments