fix: only render yaml/directive block when it is not empty

This commit is contained in:
Marcel Beck 2023-08-04 15:19:45 +02:00
parent eec16d3abe
commit cbd8fa2006

View file

@ -179,10 +179,15 @@ function initMermaid( update, attrs ) {
};
var serializeGraph = function( graph ){
if (JSON.stringify(graph.dir) === '{}') {
return '---\n' + jsyaml.dump(graph.yaml) + '---\n' + graph.content;
yamlPart = '';
dirPart = '';
if (JSON.stringify(graph.dir) !== '{}') {
dirPart = '%%{init: ' + JSON.stringify(graph.dir) + '}%%\n';
}
return '---\n' + jsyaml.dump(graph.yaml) + '---\n' + '%%{init: ' + JSON.stringify(graph.dir) + '}%%\n' + graph.content;
if (JSON.stringify(graph.yaml) !== '{}') {
yamlPart = '---\n' + jsyaml.dump(graph.yaml) + '---\n';
}
return yamlPart + dirPart + graph.content;
};
var init_func = function( attrs ){