Workaround that graphviz might not recover from error
This commit is contained in:
parent
c1b5e74cf9
commit
08b04e9528
1 changed files with 22 additions and 12 deletions
|
@ -11,6 +11,7 @@ var PDFObject = require('pdfobject');
|
|||
var S = require('string');
|
||||
var saveAs = require('file-saver').saveAs;
|
||||
require('../vendor/md-toc');
|
||||
var Viz = require("viz.js");
|
||||
|
||||
//auto update last change
|
||||
window.createtime = null;
|
||||
|
@ -335,10 +336,8 @@ function finishView(view) {
|
|||
}
|
||||
});
|
||||
//graphviz
|
||||
var Viz = require("viz.js");
|
||||
var graphvizs = view.find("div.graphviz.raw").removeClass("raw");
|
||||
graphvizs.each(function (key, value) {
|
||||
try {
|
||||
function parseGraphviz(key, value) {
|
||||
var $value = $(value);
|
||||
var $ele = $(value).parent().parent();
|
||||
|
||||
|
@ -348,10 +347,21 @@ function finishView(view) {
|
|||
|
||||
$ele.addClass('graphviz');
|
||||
$value.children().unwrap().unwrap();
|
||||
}
|
||||
graphvizs.each(function (key, value) {
|
||||
try {
|
||||
parseGraphviz(key, value);
|
||||
} catch (err) {
|
||||
// workaround for graphviz not recover from error
|
||||
try {
|
||||
parseGraphviz(key, value);
|
||||
} catch (err) {
|
||||
var $value = $(value);
|
||||
$value.unwrap();
|
||||
$value.parent().append('<div class="alert alert-warning">' + err + '</div>');
|
||||
console.warn(err);
|
||||
}
|
||||
}
|
||||
});
|
||||
//mermaid
|
||||
var mermaids = view.find("div.mermaid.raw").removeClass("raw");
|
||||
|
|
Loading…
Reference in a new issue