Răsfoiți Sursa

Мелкий рефакторинг, поправки парсера

Book Pauk 6 ani în urmă
părinte
comite
7fe41d6f77

+ 2 - 2
client/components/Reader/TextPage/TextPage.vue

@@ -160,8 +160,8 @@ class TextPage extends Vue {
             if (this.textAlignJustify && !line.last) {
             if (this.textAlignJustify && !line.last) {
                 const words = text.split(' ');
                 const words = text.split(' ');
                 if (words.length > 1) {
                 if (words.length > 1) {
-                    let space = canvas.width - line.width + spaceWidth*(words.length - 1);
-                    space = space/(words.length - 1);
+                    const spaceCount = words.length - 1;
+                    const space = (canvas.width - line.width + spaceWidth*spaceCount)/spaceCount;
 
 
                     let x = 0;
                     let x = 0;
                     for (const word of words) {
                     for (const word of words) {

+ 5 - 7
client/components/Reader/share/BookParser.js

@@ -109,7 +109,11 @@ export default class BookParser {
         });
         });
 
 
         parser.on('textNode', (text) => {
         parser.on('textNode', (text) => {
-            text = text.trim();
+            if (text != ' ' && text.trim() == '')
+                text = text.trim();
+
+            if (text == '')
+                return;
 
 
             switch (path) {
             switch (path) {
                 case '/FictionBook/description/title-info/author/first-name':
                 case '/FictionBook/description/title-info/author/first-name':
@@ -144,16 +148,10 @@ export default class BookParser {
                     fb2.annotation += text;
                     fb2.annotation += text;
             }
             }
 
 
-            if (text == '')
-                return;
-
             if (path.indexOf('/FictionBook/body/title') == 0) {
             if (path.indexOf('/FictionBook/body/title') == 0) {
                 newParagraph(text, text.length);
                 newParagraph(text, text.length);
             }
             }
 
 
-            if (text == '')
-                return;
-
             if (path.indexOf('/FictionBook/body/section') == 0) {
             if (path.indexOf('/FictionBook/body/section') == 0) {
                 switch (tag) {
                 switch (tag) {
                     case 'p':
                     case 'p':