FIX: Correct graph also when newline or comment separation

FIX: Correct graph also when newline or comment separation

When e.g. two nodes were separated only with newlines and/or comments, only one node was generated which hade the name of two node’s name concatenated because the newlines and comments has been removed.

The solution is to not remove anything within the DOT source code. Instead only trimming of whitespace at the beginning and end is made since this can be considered part of the [graphviz] BBCode tags.

Fixes https://github.com/discourse/discourse-graphviz/issues/2

diff --git a/assets/javascripts/discourse-markdown/discourse-graphviz.js.es6 b/assets/javascripts/discourse-markdown/discourse-graphviz.js.es6
index f4158c3..38dd909 100644
--- a/assets/javascripts/discourse-markdown/discourse-graphviz.js.es6
+++ b/assets/javascripts/discourse-markdown/discourse-graphviz.js.es6
@@ -22,11 +22,8 @@ export function setup(helper) {
           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, "")
+            content
           );
           const inputEngine = state.md.utils.escapeHtml(tagInfo.attrs.engine);
           const engine = engines.includes(inputEngine)
diff --git a/assets/javascripts/initializers/discourse-graphviz.js.es6 b/assets/javascripts/initializers/discourse-graphviz.js.es6
index 91fb18d..c358b69 100644
--- a/assets/javascripts/initializers/discourse-graphviz.js.es6
+++ b/assets/javascripts/initializers/discourse-graphviz.js.es6
@@ -18,7 +18,7 @@ export default {
   },
 
   renderGraph($container) {
-    const graphDefinition = $container.text();
+    const graphDefinition = $container.text().trim();
     const engine = $container.attr("data-engine");
 
     const $spinner = $("<div class='spinner tiny'></div>");

GitHub sha: 063e702f

This commit appears in #4 which was merged by SamSaffron.