From 69afd7720a76243fc1a0b0be43d67bc7d1b54ade Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sat, 23 Feb 2019 20:45:21 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20fb2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/share/BookParser.js | 10 +++++++--- server/core/BookConverter/index.js | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/client/components/Reader/share/BookParser.js b/client/components/Reader/share/BookParser.js index 1e361eb0..f083d9b6 100644 --- a/client/components/Reader/share/BookParser.js +++ b/client/components/Reader/share/BookParser.js @@ -46,6 +46,7 @@ export default class BookParser { let space = 0; let inPara = false; let isFirstSection = true; + let isFirstTitlePara = false; this.binary = {}; let binaryId = ''; @@ -202,6 +203,7 @@ export default class BookParser { if (path.indexOf('/fictionbook/body') == 0) { if (tag == 'title') { newParagraph(' ', 1); + isFirstTitlePara = true; bold = true; center = true; } @@ -217,13 +219,15 @@ export default class BookParser { } if ((tag == 'p' || tag == 'empty-line' || tag == 'v')) { - newParagraph(' ', 1); - if (tag == 'p') + if (!(tag == 'p' && center && isFirstTitlePara)) + newParagraph(' ', 1); + if (tag == 'p') { inPara = true; + isFirstTitlePara = false; + } } if (tag == 'subtitle') { - newParagraph(' ', 1); bold = true; } diff --git a/server/core/BookConverter/index.js b/server/core/BookConverter/index.js index 4b383ad1..cc493155 100644 --- a/server/core/BookConverter/index.js +++ b/server/core/BookConverter/index.js @@ -263,13 +263,13 @@ class BookConverter { }; const growParagraph = (text) => { + if (!node._p) + openTag('p'); if (node._n == 'p' && node._a.length == 0) text = text.trimLeft(); node._a.push({_t: text}); }; - openTag('p'); - const onStartNode = (elemName, tail, singleTag, cutCounter, cutTag) => {// eslint-disable-line no-unused-vars if (elemName == '') return;