From 0d5ee6d1b4a81cec59a4ec4fb34ec08b1641182f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sat, 19 Nov 2022 00:00:31 +0100 Subject: [PATCH] mermaid: avoid leading whitespace #394 to avoid brittle initialization of mindmap graph --- static/js/theme.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/static/js/theme.js b/static/js/theme.js index 946022ad2a..f792090143 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -125,11 +125,14 @@ function initMermaid( update, attrs ) { dir = JSON.parse( '{ "dummy": ' + m[2] ).dummy; content = graph.substring( d.lastIndex ); } + content = content.trim(); return { dir: dir, content: content }; }; var serializeGraph = function( graph ){ - return '%%{init: ' + JSON.stringify( graph.dir ) + '}%%\n' + graph.content; + var s = '%%{init: ' + JSON.stringify( graph.dir ) + '}%%\n'; + s += graph.content; + return s; }; var init_func = function( attrs ){