Поправки форматирования fb2

This commit is contained in:
Book Pauk
2019-02-23 20:45:21 +07:00
parent a75590c493
commit 69afd7720a
2 changed files with 9 additions and 5 deletions

View File

@@ -46,6 +46,7 @@ export default class BookParser {
let space = 0; let space = 0;
let inPara = false; let inPara = false;
let isFirstSection = true; let isFirstSection = true;
let isFirstTitlePara = false;
this.binary = {}; this.binary = {};
let binaryId = ''; let binaryId = '';
@@ -202,6 +203,7 @@ export default class BookParser {
if (path.indexOf('/fictionbook/body') == 0) { if (path.indexOf('/fictionbook/body') == 0) {
if (tag == 'title') { if (tag == 'title') {
newParagraph(' ', 1); newParagraph(' ', 1);
isFirstTitlePara = true;
bold = true; bold = true;
center = true; center = true;
} }
@@ -217,13 +219,15 @@ export default class BookParser {
} }
if ((tag == 'p' || tag == 'empty-line' || tag == 'v')) { if ((tag == 'p' || tag == 'empty-line' || tag == 'v')) {
newParagraph(' ', 1); if (!(tag == 'p' && center && isFirstTitlePara))
if (tag == 'p') newParagraph(' ', 1);
if (tag == 'p') {
inPara = true; inPara = true;
isFirstTitlePara = false;
}
} }
if (tag == 'subtitle') { if (tag == 'subtitle') {
newParagraph(' ', 1);
bold = true; bold = true;
} }

View File

@@ -263,13 +263,13 @@ class BookConverter {
}; };
const growParagraph = (text) => { const growParagraph = (text) => {
if (!node._p)
openTag('p');
if (node._n == 'p' && node._a.length == 0) if (node._n == 'p' && node._a.length == 0)
text = text.trimLeft(); text = text.trimLeft();
node._a.push({_t: text}); node._a.push({_t: text});
}; };
openTag('p');
const onStartNode = (elemName, tail, singleTag, cutCounter, cutTag) => {// eslint-disable-line no-unused-vars const onStartNode = (elemName, tail, singleTag, cutCounter, cutTag) => {// eslint-disable-line no-unused-vars
if (elemName == '') if (elemName == '')
return; return;