FIX: auto strip comments from graph definition

FIX: auto strip comments from graph definition

diff --git a/assets/javascripts/discourse-markdown/discourse-graphviz.js.es6 b/assets/javascripts/discourse-markdown/discourse-graphviz.js.es6
index 64451e2..d9e0db5 100644
--- a/assets/javascripts/discourse-markdown/discourse-graphviz.js.es6
+++ b/assets/javascripts/discourse-markdown/discourse-graphviz.js.es6
@@ -17,6 +17,10 @@ export function setup(helper) {
         replace: function(state, tagInfo, content) {
           const engines = ["dot", "neato", "circo", "fdp", "osage", "twopi"];
           const token = state.push("html_raw", "", 0);
+
+          // remove comments
+          content = content.replace(/^\s*?\/\/.*$/m, "");
+
           const escaped = state.md.utils.escapeHtml(
             content.replace(/[\r\n\t]/g, "")
           );

GitHub sha: 2756f7c6

2 Likes