Explorar o código

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

Book Pauk %!s(int64=6) %!d(string=hai) anos
pai
achega
2e477e6c99
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      server/core/BookConverter/index.js

+ 3 - 1
server/core/BookConverter/index.js

@@ -10,6 +10,7 @@ const FileDetector = require('../FileDetector');
 
 const repSpaces = (text) => text.replace(/ |[\t\n\r]/g, ' ');
 const repSpaces2 = (text) => text.replace(/[\n\r]/g, '');
+const repSpaces3 = (text) => text.replace(/ /g, ' ');
 
 class BookConverter {
     constructor() {
@@ -384,6 +385,7 @@ class BookConverter {
                         if (inSubtitle) {
                             closeTag('subtitle');
                             inSubtitle = false;
+                            isFirstPara = false;
                         }
 
                         if (inJustify) {
@@ -442,7 +444,7 @@ class BookConverter {
                 growParagraph(`${tOpen}${text}${tClose}`);
         };
 
-        sax.parseSync(repSpaces(this.decode(data).toString()), {
+        sax.parseSync(repSpaces3(this.decode(data).toString()), {
             onStartNode, onEndNode, onTextNode, onComment,
             innerCut: new Set(['head', 'script', 'style'])
         });