From e1cdff0c4009f19cdf5b0bcc9cec43ab4f889721 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 8 Feb 2019 16:34:45 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D0=B0=D1=80=D1=81=D0=B8=D0=BD=D0=B3=D0=B0?= =?UTF-8?q?=20fb2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/share/BookParser.js | 26 +++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/client/components/Reader/share/BookParser.js b/client/components/Reader/share/BookParser.js index 0319822e..f7ed890c 100644 --- a/client/components/Reader/share/BookParser.js +++ b/client/components/Reader/share/BookParser.js @@ -36,6 +36,7 @@ export default class BookParser { let tag = ''; let center = false; let bold = false; + let italic = false; let paraIndex = -1; let paraOffset = 0; @@ -95,7 +96,7 @@ export default class BookParser { tag = elemName; path += '/' + elemName; - if ((tag == 'p' || tag == 'empty-line') && path.indexOf('/fictionbook/body/section') == 0) { + if ((tag == 'p' || tag == 'empty-line' || tag == 'v') && path.indexOf('/fictionbook/body/section') == 0) { newParagraph(' ', 1); } @@ -104,15 +105,21 @@ export default class BookParser { } if (tag == 'title') { - //newParagraph(' ', 1); bold = true; center = true; } if (tag == 'subtitle') { - //newParagraph(' ', 1); bold = true; } + + if (tag == 'epigraph') { + italic = true; + } + + if (tag == 'stanza') { + newParagraph(' ', 1); + } }; const onEndNode = (elemName) => {// eslint-disable-line no-unused-vars @@ -126,8 +133,17 @@ export default class BookParser { center = false; } - if (tag == 'subtitle') + if (tag == 'subtitle') { bold = false; + } + + if (tag == 'epigraph') { + italic = false; + } + + if (tag == 'stanza') { + newParagraph(' ', 1); + } path = path.substr(0, path.length - tag.length - 1); let i = path.lastIndexOf('/'); @@ -187,8 +203,10 @@ export default class BookParser { let tOpen = (center ? '
' : ''); tOpen += (bold ? '' : ''); + tOpen += (italic ? '' : ''); let tClose = (center ? '
' : ''); tClose += (bold ? '' : ''); + tClose += (italic ? '' : ''); if (path.indexOf('/fictionbook/body/title') == 0) { newParagraph(`${tOpen}${text}${tClose}`, text.length, true);