From cbd8fa2006377416c876fc95c1a1d53c16b2ffd4 Mon Sep 17 00:00:00 2001 From: Marcel Beck Date: Fri, 4 Aug 2023 15:19:45 +0200 Subject: [PATCH] fix: only render yaml/directive block when it is not empty --- static/js/theme.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/static/js/theme.js b/static/js/theme.js index 5744cf9182..8e84ebf040 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -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 ){