From 23353a49602de031e35693aa6914345185d57a13 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 13 Jul 2022 16:23:52 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D1=81=D0=B8=D0=BD=D0=B3=20fb2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/share/BookParser.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/client/components/Reader/share/BookParser.js b/client/components/Reader/share/BookParser.js index 025880df..259e0d28 100644 --- a/client/components/Reader/share/BookParser.js +++ b/client/components/Reader/share/BookParser.js @@ -3,6 +3,7 @@ import sax from '../../../../server/core/sax'; import * as utils from '../../../share/utils'; const maxImageLineCount = 100; +const maxParaTextLength = 10000; // defaults const defaultSettings = { @@ -226,13 +227,25 @@ export default class BookParser { paraOffset += len; }; - const growParagraph = (text, len) => { + const growParagraph = (text, len, textRaw) => { if (paraIndex < 0) { newParagraph(); growParagraph(text, len); return; } + //ограничение на размер куска текста в параграфе + if (textRaw && textRaw.length > maxParaTextLength) { + while (textRaw.length > 0) { + const textPart = textRaw.substring(0, maxParaTextLength); + textRaw = textRaw.substring(maxParaTextLength); + + newParagraph(); + growParagraph(textPart, textPart.length); + } + return; + } + if (inSubtitle) { curSubtitle.title += text; } else if (inTitle) { @@ -536,7 +549,7 @@ export default class BookParser { tClose += (center ? '' : ''); if (text != ' ') - growParagraph(`${tOpen}${text}${tClose}`, text.length); + growParagraph(`${tOpen}${text}${tClose}`, text.length, text); else growParagraph(' ', 1); }