mermaid: avoid leading whitespace #394

to avoid brittle initialization of mindmap graph
This commit is contained in:
Sören Weber 2022-11-19 00:00:31 +01:00
parent c7f6cbf71b
commit 0d5ee6d1b4
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -125,11 +125,14 @@ function initMermaid( update, attrs ) {
dir = JSON.parse( '{ "dummy": ' + m[2] ).dummy; dir = JSON.parse( '{ "dummy": ' + m[2] ).dummy;
content = graph.substring( d.lastIndex ); content = graph.substring( d.lastIndex );
} }
content = content.trim();
return { dir: dir, content: content }; return { dir: dir, content: content };
}; };
var serializeGraph = function( graph ){ 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 ){ var init_func = function( attrs ){