@@ -10,15 +10,21 @@ package org.readium.r2.streamer.parser.readium
10
10
11
11
import android.content.Context
12
12
import org.readium.r2.shared.DelicateReadiumApi
13
+ import org.readium.r2.shared.ExperimentalReadiumApi
13
14
import org.readium.r2.shared.InternalReadiumApi
14
15
import org.readium.r2.shared.publication.Manifest
15
16
import org.readium.r2.shared.publication.Publication
16
17
import org.readium.r2.shared.publication.services.InMemoryCacheService
17
18
import org.readium.r2.shared.publication.services.PerResourcePositionsService
18
19
import org.readium.r2.shared.publication.services.WebPositionsService
19
20
import org.readium.r2.shared.publication.services.cacheServiceFactory
21
+ import org.readium.r2.shared.publication.services.content.DefaultContentService
22
+ import org.readium.r2.shared.publication.services.content.contentServiceFactory
23
+ import org.readium.r2.shared.publication.services.content.iterators.HtmlResourceContentIterator
20
24
import org.readium.r2.shared.publication.services.locatorServiceFactory
21
25
import org.readium.r2.shared.publication.services.positionsServiceFactory
26
+ import org.readium.r2.shared.publication.services.search.StringSearchService
27
+ import org.readium.r2.shared.publication.services.search.searchServiceFactory
22
28
import org.readium.r2.shared.util.AbsoluteUrl
23
29
import org.readium.r2.shared.util.DebugError
24
30
import org.readium.r2.shared.util.Try
@@ -52,6 +58,7 @@ import timber.log.Timber
52
58
* of positions in a reflowable resource of a web publication conforming to the
53
59
* EPUB profile.
54
60
*/
61
+ @OptIn(ExperimentalReadiumApi ::class )
55
62
public class ReadiumWebPubParser (
56
63
private val context : Context ? = null ,
57
64
private val httpClient : HttpClient ,
@@ -115,6 +122,16 @@ public class ReadiumWebPubParser(
115
122
else ->
116
123
null
117
124
}
125
+
126
+ // Add content- and search-service for WebPubs with HTML contents.
127
+ if (manifest.readingOrder.any { it.mediaType?.isHtml == true }) {
128
+ contentServiceFactory = DefaultContentService .createFactory(
129
+ resourceContentIteratorFactories = listOf (
130
+ HtmlResourceContentIterator .Factory ()
131
+ )
132
+ )
133
+ searchServiceFactory = StringSearchService .createDefaultFactory()
134
+ }
118
135
}
119
136
120
137
val publicationBuilder = Publication .Builder (manifest, container, servicesBuilder)
0 commit comments