From 8810e7709678fc6f62a1e487926c55415b7c1a57 Mon Sep 17 00:00:00 2001 From: sujitv19196 Date: Wed, 11 Oct 2023 15:30:55 -0500 Subject: [PATCH] add check for text existing and comments --- src/entities/EPubs/structs/EPubChapterLikeData.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/entities/EPubs/structs/EPubChapterLikeData.js b/src/entities/EPubs/structs/EPubChapterLikeData.js index faf5151cc..aef88e309 100644 --- a/src/entities/EPubs/structs/EPubChapterLikeData.js +++ b/src/entities/EPubs/structs/EPubChapterLikeData.js @@ -7,14 +7,16 @@ import EPubImageData from './EPubImageData'; function _buildContentsFromItems(items) { const content = []; for (const item of items) { - if (item.image) { - const altText = item.ocrPhrases ? 'OCR Phrases: ' + item.ocrPhrases : '' + if (item.image) { // if there is an image + const altText = item.ocrPhrases ? 'OCR Phrases: ' + item.ocrPhrases : '' // add in OCR data const imageData = new EPubImageData({src: item.image, alt: altText}); content.push(imageData) } - const text = item.text - if (_.trim(text)) { - content.push(text); + if (item.text) { // if there is text + const text = item.text + if (_.trim(text)) { + content.push(text); + } } } return content;