Skip to content

Commit

Permalink
mermaid: in doubt, set variants mermaid theme into yaml #603 #601
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Aug 5, 2023
1 parent a718c05 commit b2b5277
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions static/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,14 @@ function initMermaid( update, attrs ) {
document.querySelectorAll('.mermaid').forEach( function( element ){
var parse = parseGraph( decodeHTML( element.innerHTML ) );

if( JSON.stringify(parse.dir) === '{}' ){
if( parse.yaml.theme ){
parse.yaml.relearn_user_theme = true;
}
if( !parse.yaml.relearn_user_theme ){
parse.yaml.theme = theme;
}
} else {
if( parse.dir.theme ){
parse.dir.relearn_user_theme = true;
}
if( !parse.dir.relearn_user_theme ){
parse.dir.theme = theme;
}
if( parse.yaml.theme ){
parse.yaml.relearn_user_theme = true;
}
if( parse.dir.theme ){
parse.dir.relearn_user_theme = true;
}
if( !parse.yaml.relearn_user_theme && !parse.dir.relearn_user_theme ){
parse.yaml.theme = theme;
}
is_initialized = true;

Expand Down Expand Up @@ -239,7 +233,7 @@ function initMermaid( update, attrs ) {
}
is_initialized = true;

parse.dir.theme = theme;
parse.yaml.theme = theme;
var graph = serializeGraph( parse );
element.removeAttribute('data-processed');
element.innerHTML = graph;
Expand Down

0 comments on commit b2b5277

Please sign in to comment.