about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndrew Dolgov <noreply@fakecake.org>2020-09-13 21:42:11 +0300
committerAndrew Dolgov <noreply@fakecake.org>2020-09-13 21:42:11 +0300
commita50e03516bcdc5aceee1abddea7e750bfb90ea91 (patch)
tree57478199e8e4574d339e677082ae94fd95ab9bae
parenta57a672d537a5d2a78186c987237c5f941007a29 (diff)
downloadthe-epube-a50e03516bcdc5aceee1abddea7e750bfb90ea91.tar.gz
the-epube-a50e03516bcdc5aceee1abddea7e750bfb90ea91.tar.xz
use spine hook to properly cleanup document before display
-rw-r--r--js/reader.js33
1 files changed, 17 insertions, 16 deletions
diff --git a/js/reader.js b/js/reader.js
index 5410fd4..246d203 100644
--- a/js/reader.js
+++ b/js/reader.js
@@ -420,6 +420,21 @@ const Reader = {
 
 		});
 
+		/* embedded styles may conflict with our font sizes, etc */
+		book.spine.hooks.content.register(function(doc, section) {
+
+			$(doc).find("p")
+					.filter((i, e) => { if ($(e).text().length >= MIN_LENGTH_TO_JUSTIFY) return e; })
+						.css("text-align", "justify");
+
+			$(doc).find("p, span, em, strong, body")
+					.attr("class", "")
+					.css("color", "")
+					.css("background", "")
+					.css("background-color", "");
+
+		});
+
 		book.ready.then(function() {
 
 			const meta = book.package.metadata;
@@ -645,7 +660,8 @@ const Reader = {
 					'font-size': fontSize,
 					'font-family': "'" + fontFamily + "'",
 					'line-height': lineHeight,
-					'text-align': 'justify'
+					'text-align': 'justify',
+					'text-indent': '1em'
 				}
 			});
 
@@ -710,21 +726,6 @@ const Reader = {
 				console.log('applying rendition theme', theme, 'to', c, c.document);
 
 				$(c.document).find("#theme_css").text(Reader.Loader._res_data[theme_url]);
-
-				$(c.document).find("p")
-					.filter((i, e) => { if ($(e).text().length >= MIN_LENGTH_TO_JUSTIFY) return e; })
-						.css("text-align", "justify");
-
-				/* embedded styles may conflict with our font sizes, etc */
-				$(c.document).find("p, span, em, strong, body")
-						.attr("class", "")
-						.css("color", "")
-						.css("background", "")
-						.css("background-color", "")
-
-				$(c.document).find("p")
-						.css("text-indent", "1em");
-
 			});
 
 		});