diff --git a/src/resources/markdown_template.js b/src/resources/markdown_template.js
index 1ac22293..bbc021ca 100644
--- a/src/resources/markdown_template.js
+++ b/src/resources/markdown_template.js
@@ -1546,6 +1546,10 @@ var htmlToText = function(identifier, id, timeStamp, html) {
ts.addRule('mark', {
filter: 'mark',
replacement: function(content, node, options) {
+ if (!content) {
+ return '';
+ }
+
return '' + content + '';
}
});
@@ -1576,6 +1580,44 @@ var htmlToText = function(identifier, id, timeStamp, html) {
}
});
+ ts.remove(['head', 'style']);
+
+ var subEnabled = false, supEnabled = false;
+ if (typeof VMarkdownitOption != "undefined") {
+ subEnabled = VMarkdownitOption.sub;
+ supEnabled = VMarkdownitOption.sup;
+ }
+
+ ts.addRule('sub_fix', {
+ filter: 'sub',
+ replacement: function (content, node, options) {
+ if (!content) {
+ return '';
+ }
+
+ if (subEnabled) {
+ return '~' + content + '~';
+ } else {
+ return '' + content + '';
+ }
+ }
+ });
+
+ ts.addRule('sup_fix', {
+ filter: 'sup',
+ replacement: function (content, node, options) {
+ if (!content) {
+ return '';
+ }
+
+ if (supEnabled) {
+ return '^' + content + '^';
+ } else {
+ return '' + content + '';
+ }
+ }
+ });
+
var markdown = ts.turndown(html);
content.htmlToTextCB(identifier, id, timeStamp, markdown);
};
diff --git a/src/resources/mathjax_preview.js b/src/resources/mathjax_preview.js
index b00faa91..a765fbcb 100644
--- a/src/resources/mathjax_preview.js
+++ b/src/resources/mathjax_preview.js
@@ -72,7 +72,7 @@ var previewMathJax = function(identifier, id, timeStamp, text, isHtml) {
p,
[postProcessMathJax, identifier, id, timeStamp, p, isBlock]]);
} catch (err) {
- console.log("err: " + err);
+ content.setLog("err: " + err);
content.mathjaxResultReady(identifier, id, timeStamp, 'png', '');
contentDiv.removeChild(p);
delete p;
@@ -94,7 +94,7 @@ var postProcessMathJax = function(identifier, id, timeStamp, container, isBlock)
contentDiv.removeChild(container);
delete container;
}).catch(function (err) {
- console.log("err: " + err);
+ content.setLog("err: " + err);
content.mathjaxResultReady(identifier, id, timeStamp, 'png', '');
contentDiv.removeChild(container);
delete container;
@@ -132,7 +132,7 @@ var previewDiagram = function(identifier, id, timeStamp, lang, text) {
try {
var graph = flowchart.parse(text);
} catch (err) {
- console.log("err: " + err);
+ content.setLog("err: " + err);
content.diagramResultReady(identifier, id, timeStamp, 'png', '');
return;
}
@@ -152,7 +152,7 @@ var previewDiagram = function(identifier, id, timeStamp, lang, text) {
try {
graph.drawSVG(div.id);
} catch (err) {
- console.log("err: " + err);
+ content.setLog("err: " + err);
contentDiv.removeChild(div);
delete div;
content.diagramResultReady(identifier, id, timeStamp, 'png', '');
@@ -167,7 +167,7 @@ var previewDiagram = function(identifier, id, timeStamp, lang, text) {
text,
function(){});
} catch (err) {
- console.log("err: " + err);
+ content.setLog("err: " + err);
content.diagramResultReady(identifier, id, timeStamp, 'png', '');
return;
}
@@ -197,7 +197,7 @@ var previewDiagram = function(identifier, id, timeStamp, lang, text) {
contentDiv.removeChild(div);
delete div;
}).catch(function (err) {
- console.log("err: " + err);
+ content.setLog("err: " + err);
contentDiv.removeChild(div);
content.diagramResultReady(identifier, id, timeStamp, 'png', '');
delete div;