Улучшение парсинга плохих fb2
This commit is contained in:
@@ -3,6 +3,7 @@ import sax from '../../../../server/core/sax';
|
|||||||
import * as utils from '../../../share/utils';
|
import * as utils from '../../../share/utils';
|
||||||
|
|
||||||
const maxImageLineCount = 100;
|
const maxImageLineCount = 100;
|
||||||
|
const maxParaLength = 10000;
|
||||||
const maxParaTextLength = 10000;
|
const maxParaTextLength = 10000;
|
||||||
|
|
||||||
// defaults
|
// defaults
|
||||||
@@ -228,6 +229,7 @@ export default class BookParser {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const growParagraph = (text, len, textRaw) => {
|
const growParagraph = (text, len, textRaw) => {
|
||||||
|
//начальный параграф
|
||||||
if (paraIndex < 0) {
|
if (paraIndex < 0) {
|
||||||
newParagraph();
|
newParagraph();
|
||||||
growParagraph(text, len);
|
growParagraph(text, len);
|
||||||
@@ -253,6 +255,14 @@ export default class BookParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const p = para[paraIndex];
|
const p = para[paraIndex];
|
||||||
|
|
||||||
|
//ограничение на размер параграфа
|
||||||
|
if (p.length > maxParaLength) {
|
||||||
|
newParagraph();
|
||||||
|
growParagraph(text, len);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
p.length += len;
|
p.length += len;
|
||||||
p.text += text;
|
p.text += text;
|
||||||
paraOffset += len;
|
paraOffset += len;
|
||||||
|
|||||||
Reference in New Issue
Block a user