Поправки багов
This commit is contained in:
@@ -73,6 +73,7 @@ export default class DrawHelper {
|
|||||||
|
|
||||||
let lineText = '';
|
let lineText = '';
|
||||||
let center = false;
|
let center = false;
|
||||||
|
let space = false;
|
||||||
let j = 0;
|
let j = 0;
|
||||||
//формируем строку
|
//формируем строку
|
||||||
for (const part of line.parts) {
|
for (const part of line.parts) {
|
||||||
@@ -96,6 +97,7 @@ export default class DrawHelper {
|
|||||||
lineText += `${tOpen}${text}${tClose}`;
|
lineText += `${tOpen}${text}${tClose}`;
|
||||||
|
|
||||||
center = center || part.style.center;
|
center = center || part.style.center;
|
||||||
|
space = space || part.style.space;
|
||||||
|
|
||||||
//избражения
|
//избражения
|
||||||
//image: {local: Boolean, inline: Boolean, id: String, imageLine: Number, lineCount: Number, paraIndex: Number},
|
//image: {local: Boolean, inline: Boolean, id: String, imageLine: Number, lineCount: Number, paraIndex: Number},
|
||||||
@@ -125,8 +127,11 @@ export default class DrawHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const centerStyle = (center ? `text-align: center; text-align-last: center; width: ${this.w}px` : '')
|
const centerStyle = (center ? `text-align: center; text-align-last: center; width: ${this.w}px` : '')
|
||||||
if (line.first && !center)
|
if ((line.first || space) && !center) {
|
||||||
lineText = `<span style="display: inline-block; margin-left: ${this.p}px"></span>${lineText}`;
|
let p = (line.first ? this.p : 0);
|
||||||
|
p = (space ? p + this.p : p);
|
||||||
|
lineText = `<span style="display: inline-block; margin-left: ${p}px"></span>${lineText}`;
|
||||||
|
}
|
||||||
|
|
||||||
if (line.last || center)
|
if (line.last || center)
|
||||||
lineText = `<span style="display: inline-block; ${centerStyle}">${lineText}</span>`;
|
lineText = `<span style="display: inline-block; ${centerStyle}">${lineText}</span>`;
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ export default class BookParser {
|
|||||||
let center = false;
|
let center = false;
|
||||||
let bold = false;
|
let bold = false;
|
||||||
let italic = false;
|
let italic = false;
|
||||||
|
let space = false;
|
||||||
|
|
||||||
this.binary = {};
|
this.binary = {};
|
||||||
let binaryId = '';
|
let binaryId = '';
|
||||||
let binaryType = '';
|
let binaryType = '';
|
||||||
@@ -177,6 +179,7 @@ export default class BookParser {
|
|||||||
|
|
||||||
if (tag == 'epigraph') {
|
if (tag == 'epigraph') {
|
||||||
italic = true;
|
italic = true;
|
||||||
|
space = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag == 'poem') {
|
if (tag == 'poem') {
|
||||||
@@ -184,7 +187,7 @@ export default class BookParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tag == 'text-author') {
|
if (tag == 'text-author') {
|
||||||
newParagraph(' <s> <s> <s> ', 4);
|
space = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -211,11 +214,16 @@ export default class BookParser {
|
|||||||
|
|
||||||
if (tag == 'epigraph') {
|
if (tag == 'epigraph') {
|
||||||
italic = false;
|
italic = false;
|
||||||
|
space = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag == 'stanza') {
|
if (tag == 'stanza') {
|
||||||
newParagraph(' ', 1);
|
newParagraph(' ', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tag == 'text-author') {
|
||||||
|
space = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
path = path.substr(0, path.length - tag.length - 1);
|
path = path.substr(0, path.length - tag.length - 1);
|
||||||
@@ -277,7 +285,9 @@ export default class BookParser {
|
|||||||
let tOpen = (center ? '<center>' : '');
|
let tOpen = (center ? '<center>' : '');
|
||||||
tOpen += (bold ? '<strong>' : '');
|
tOpen += (bold ? '<strong>' : '');
|
||||||
tOpen += (italic ? '<emphasis>' : '');
|
tOpen += (italic ? '<emphasis>' : '');
|
||||||
let tClose = (italic ? '</emphasis>' : '');
|
tOpen += (space ? '<space>' : '');
|
||||||
|
let tClose = (space ? '</space>' : '');
|
||||||
|
tClose += (italic ? '</emphasis>' : '');
|
||||||
tClose += (bold ? '</strong>' : '');
|
tClose += (bold ? '</strong>' : '');
|
||||||
tClose += (center ? '</center>' : '');
|
tClose += (center ? '</center>' : '');
|
||||||
|
|
||||||
@@ -352,7 +362,7 @@ export default class BookParser {
|
|||||||
|
|
||||||
splitToStyle(s) {
|
splitToStyle(s) {
|
||||||
let result = [];/*array of {
|
let result = [];/*array of {
|
||||||
style: {bold: Boolean, italic: Boolean, center: Boolean},
|
style: {bold: Boolean, italic: Boolean, center: Boolean, space: Number},
|
||||||
image: {local: Boolean, inline: Boolean, id: String},
|
image: {local: Boolean, inline: Boolean, id: String},
|
||||||
text: String,
|
text: String,
|
||||||
}*/
|
}*/
|
||||||
@@ -378,19 +388,23 @@ export default class BookParser {
|
|||||||
case 'center':
|
case 'center':
|
||||||
style.center = true;
|
style.center = true;
|
||||||
break;
|
break;
|
||||||
|
case 'space': {
|
||||||
|
style.space = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'image': {
|
case 'image': {
|
||||||
let attrs = sax.getAttrsSync(tail);
|
let attrs = sax.getAttrsSync(tail);
|
||||||
let id = attrs.href.value;
|
let id = attrs.href.value;
|
||||||
if (id) {
|
if (id) {
|
||||||
let local = false;
|
let local = false;
|
||||||
if (id[0] == '#') {
|
if (id[0] == '#') {
|
||||||
id = id.substr(1);
|
id = id.substr(1);
|
||||||
local = true;
|
local = true;
|
||||||
}
|
|
||||||
image = {local, inline: false, id};
|
|
||||||
}
|
}
|
||||||
break;
|
image = {local, inline: false, id};
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -405,6 +419,9 @@ export default class BookParser {
|
|||||||
case 'center':
|
case 'center':
|
||||||
style.center = false;
|
style.center = false;
|
||||||
break;
|
break;
|
||||||
|
case 'space':
|
||||||
|
style.space = false;
|
||||||
|
break;
|
||||||
case 'image':
|
case 'image':
|
||||||
image = {};
|
image = {};
|
||||||
break;
|
break;
|
||||||
@@ -588,7 +605,7 @@ export default class BookParser {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const words = part.text.split(' ');
|
let words = part.text.split(' ');
|
||||||
|
|
||||||
let sp1 = '';
|
let sp1 = '';
|
||||||
let sp2 = '';
|
let sp2 = '';
|
||||||
@@ -602,6 +619,7 @@ export default class BookParser {
|
|||||||
str += sp1 + word;
|
str += sp1 + word;
|
||||||
|
|
||||||
let p = (j == 0 ? parsed.p : 0);
|
let p = (j == 0 ? parsed.p : 0);
|
||||||
|
p = (style.space ? p + parsed.p : p);
|
||||||
let w = this.measureText(str, style) + p;
|
let w = this.measureText(str, style) + p;
|
||||||
let wordTail = word;
|
let wordTail = word;
|
||||||
if (w > parsed.w && prevStr != '') {
|
if (w > parsed.w && prevStr != '') {
|
||||||
|
|||||||
Reference in New Issue
Block a user