From 8e9e515a6879ac7b187b7bfdd3d7d23ba68d6d7b Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 25 Jan 2019 23:16:55 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B1=D0=B0=D0=B6=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/share/BookParser.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/client/components/Reader/share/BookParser.js b/client/components/Reader/share/BookParser.js index 4f35a2db..f81b164b 100644 --- a/client/components/Reader/share/BookParser.js +++ b/client/components/Reader/share/BookParser.js @@ -395,6 +395,7 @@ export default class BookParser { for (let i = 0; i < words.length; i++) { const word = words[i]; ofs += word.length + (i < words.length - 1 ? 1 : 0); + if (word == '' && i > 0 && i < words.length - 1) continue; @@ -448,6 +449,7 @@ export default class BookParser { line.end = para.offset + ofs - wordTail.length - 1; if (line.end - line.begin < 0) console.error(`Parse error, empty line in paragraph ${paraIndex}`); + line.width = prevW; line.first = (j == 0); line.last = false; @@ -477,14 +479,16 @@ export default class BookParser { line.parts[line.parts.length - 1].text = t.trimRight(); prevW -= this.measureText(' ', style); } + + line.end = para.offset + para.length - 1; + if (line.end - line.begin < 0) + console.error(`Parse error, empty line in paragraph ${paraIndex}`); + + line.width = prevW; + line.first = (j == 0); + line.last = true; + lines.push(line); } - line.end = para.offset + para.length - 1; - if (line.end - line.begin < 0) - console.error(`Parse error, empty line in paragraph ${paraIndex}`); - line.width = prevW; - line.first = (j == 0); - line.last = true; - lines.push(line); parsed.lines = lines; para.parsed = parsed;