Browse Source

Улучшение парсера

Book Pauk 6 years ago
parent
commit
7194639a3b

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

@@ -41,7 +41,7 @@ class TextPage extends Vue {
     fontSize = null;
     fontName = null;
 
-    //meta = null;
+    meta = null;
 
     created() {
         this.drawHelper = new DrawHelper();

+ 9 - 1
client/components/Reader/share/BookParser.js

@@ -100,10 +100,18 @@ export default class BookParser {
             if ((tag == 'p' || tag == 'empty-line') && path.indexOf('/FictionBook/body/section') == 0) {
                 newParagraph(' ', 1);
             }
+
+            if (tag == 'emphasis' || tag == 'strong') {
+                growParagraph(`<${tag}>`, 0);
+            }
         });
 
         parser.on('endNode', (elemName, isTagStart, getStrNode) => {// eslint-disable-line no-unused-vars
             if (tag == elemName) {
+                if (tag == 'emphasis' || tag == 'strong') {
+                    growParagraph(`</${tag}>`, 0);
+                }
+
                 path = path.substr(0, path.length - tag.length - 1);
                 let i = path.lastIndexOf('/');
                 if (i >= 0) {
@@ -168,7 +176,7 @@ export default class BookParser {
                         newParagraph(text, text.length);
                         break;
                     default:
-                        growParagraph(`<${tag}>${text}</${tag}>`, text.length);
+                        growParagraph(text, text.length);
                 }
             }
         });