فهرست منبع

web: fix finishLogics() bug

Treat MathJax as an async job.
Le Tan 7 سال پیش
والد
کامیت
a5e64696ea

+ 4 - 3
src/resources/hoedown.js

@@ -14,7 +14,8 @@ marked.setOptions({
 });
 
 var updateHtml = function(html) {
-    asyncJobsCount = 0;
+    // There is at least one async job for MathJax.
+    asyncJobsCount = 1;
 
     contentDiv.innerHTML = html;
 
@@ -84,10 +85,10 @@ var updateHtml = function(html) {
             MathJax.Hub.Queue(["Typeset", MathJax.Hub, contentDiv, postProcessMathJax]);
         } catch (err) {
             content.setLog("err: " + err);
-            finishLogics();
+            finishOneAsyncJob();
         }
     } else {
-        finishLogics();
+        finishOneAsyncJob();
     }
 };
 

+ 4 - 3
src/resources/markdown-it.js

@@ -126,7 +126,8 @@ var updateText = function(text) {
         text = "[TOC]\n\n" + text;
     }
 
-    asyncJobsCount = 0;
+    // There is at least one async job for MathJax.
+    asyncJobsCount = 1;
     metaDataText = null;
 
     var needToc = mdHasTocSection(text);
@@ -149,10 +150,10 @@ var updateText = function(text) {
             MathJax.Hub.Queue(["Typeset", MathJax.Hub, contentDiv, postProcessMathJax]);
         } catch (err) {
             content.setLog("err: " + err);
-            finishLogics();
+            finishOneAsyncJob();
         }
     } else {
-        finishLogics();
+        finishOneAsyncJob();
     }
 };
 

+ 1 - 1
src/resources/markdown_template.js

@@ -1276,7 +1276,7 @@ var postProcessMathJax = function() {
         }
     }
 
-    finishLogics();
+    finishOneAsyncJob();
 };
 
 function getNodeText(el) {

+ 4 - 3
src/resources/marked.js

@@ -50,7 +50,8 @@ var updateText = function(text) {
         text = "[TOC]\n\n" + text;
     }
 
-    asyncJobsCount = 0;
+    // There is at least one async job for MathJax.
+    asyncJobsCount = 1;
 
     var needToc = mdHasTocSection(text);
     var html = markdownToHtml(text, needToc);
@@ -71,10 +72,10 @@ var updateText = function(text) {
             MathJax.Hub.Queue(["Typeset", MathJax.Hub, contentDiv, postProcessMathJax]);
         } catch (err) {
             content.setLog("err: " + err);
-            finishLogics();
+            finishOneAsyncJob();
         }
     } else {
-        finishLogics();
+        finishOneAsyncJob();
     }
 };
 

+ 4 - 3
src/resources/showdown.js

@@ -89,7 +89,8 @@ var updateText = function(text) {
         text = "[TOC]\n\n" + text;
     }
 
-    asyncJobsCount = 0;
+    // There is at least one async job for MathJax.
+    asyncJobsCount = 1;
 
     var needToc = mdHasTocSection(text);
     var html = markdownToHtml(text, needToc);
@@ -116,10 +117,10 @@ var updateText = function(text) {
             MathJax.Hub.Queue(["Typeset", MathJax.Hub, contentDiv, postProcessMathJax]);
         } catch (err) {
             content.setLog("err: " + err);
-            finishLogics();
+            finishOneAsyncJob();
         }
     } else {
-        finishLogics();
+        finishOneAsyncJob();
     }
 };
 

+ 4 - 0
src/utils/vutils.cpp

@@ -823,6 +823,10 @@ QString VUtils::generateExportHtmlTemplate(const QString &p_renderBg, bool p_inc
                              "SVG: {\n"
                                  "minScaleAdjust: 100,\n"
                                  "styles: {\n"
+/*
+FIXME: Using wkhtmltopdf, without 2em, the math formula will be very small. However,
+with 2em, if there are Chinese characters in it, the font will be a mess.
+*/
 #if defined(Q_OS_WIN)
                                    "\".MathJax_SVG\": {\n"
                                         "\"font-size\": \"2em !important\"\n"

+ 1 - 1
src/vdocument.cpp

@@ -121,7 +121,7 @@ void VDocument::setFile(const VFile *p_file)
 
 void VDocument::finishLogics()
 {
-    qDebug() << "Web side finished logics";
+    qDebug() << "Web side finished logics" << this;
     emit logicsFinished();
 }