From 1672df3dceebe885ded02530799a78d5a07be1d7 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Tue, 12 Jan 2016 07:56:29 -0600 Subject: [PATCH] Added support of graphviz --- bower.json | 3 ++- public/js/extra.js | 13 +++++++++++++ public/views/foot.ejs | 1 + public/views/pretty.ejs | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 6ff59e2..da93a2a 100644 --- a/bower.json +++ b/bower.json @@ -28,6 +28,7 @@ "moment": "~2.10.6", "handlebars": "~4.0.5", "js-url": "~2.0.2", - "socket.io-client": "~1.3.7" + "socket.io-client": "~1.3.7", + "viz.js": "~1.3.0" } } diff --git a/public/js/extra.js b/public/js/extra.js index efc89cc..07e85ac 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -167,6 +167,17 @@ function finishView(view) { console.error(err); } }); + //graphviz + var graphvizs = view.find(".graphviz.raw").removeClass("raw"); + graphvizs.each(function (key, value) { + try { + var graphviz = Viz($(value).text()); + $(value).html(graphviz); + $(value).parent().parent().replaceWith(value); + } catch (err) { + console.error(err); + } + }); //image href new window(emoji not included) var images = view.find("img.raw[src]").removeClass("raw"); images.each(function (key, value) { @@ -536,6 +547,8 @@ function highlightRender(code, lang) { return '
' + code + '
'; } else if (lang == 'flow') { return '
' + code + '
'; + } else if (lang == 'graphviz') { + return '
' + code + '
'; } var reallang = lang.replace(/\=$|\=\d+$|\=\+$/, ''); var languages = hljs.listLanguages(); diff --git a/public/views/foot.ejs b/public/views/foot.ejs index 0f2d2f5..ee04d44 100644 --- a/public/views/foot.ejs +++ b/public/views/foot.ejs @@ -38,6 +38,7 @@ + diff --git a/public/views/pretty.ejs b/public/views/pretty.ejs index 6618c54..46c559f 100644 --- a/public/views/pretty.ejs +++ b/public/views/pretty.ejs @@ -76,6 +76,7 @@ +