mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
parent
66c8fcade1
commit
c41edc86e1
1 changed files with 8 additions and 8 deletions
|
@ -164,13 +164,13 @@ function initMermaid( update, attrs ) {
|
||||||
var YAML=1;
|
var YAML=1;
|
||||||
var INIT=2;
|
var INIT=2;
|
||||||
var GRAPH=3;
|
var GRAPH=3;
|
||||||
var d = /^(?:\s*[\n\r])*(-{3}\s*[\n\r](?:.*?)[\n\r]-{3}(?:\s*[\n\r]+)+)?(?:\s*(?:%%\s*\{\s*\w+\s*:([^%]*?)%%\s*[\n\r]?))?(.*)$/s
|
var d = /^(?:\s*[\n\r])*(?:-{3}(\s*[\n\r](?:.*?)[\n\r])-{3}(?:\s*[\n\r]+)+)?(?:\s*(?:%%\s*\{\s*\w+\s*:([^%]*?)%%\s*[\n\r]?))?(.*)$/s
|
||||||
var m = d.exec( graph );
|
var m = d.exec( graph );
|
||||||
var yaml = {};
|
var yaml = {};
|
||||||
var dir = {};
|
var dir = {};
|
||||||
var content = graph;
|
var content = graph;
|
||||||
if( m && m.length == 4 ){
|
if( m && m.length == 4 ){
|
||||||
yaml = m[YAML] ? jsyaml.load(m[YAML].replaceAll("---", "")) : yaml;
|
yaml = m[YAML] ? jsyaml.load( m[YAML] ) : yaml;
|
||||||
dir = m[INIT] ? JSON.parse( '{ "init": ' + m[INIT] ).init : dir;
|
dir = m[INIT] ? JSON.parse( '{ "init": ' + m[INIT] ).init : dir;
|
||||||
content = m[GRAPH] ? m[GRAPH] : content;
|
content = m[GRAPH] ? m[GRAPH] : content;
|
||||||
}
|
}
|
||||||
|
@ -179,13 +179,13 @@ function initMermaid( update, attrs ) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var serializeGraph = function( graph ){
|
var serializeGraph = function( graph ){
|
||||||
yamlPart = '';
|
var yamlPart = '';
|
||||||
dirPart = '';
|
if( Object.keys( graph.yaml ).length ){
|
||||||
if (JSON.stringify(graph.dir) !== '{}') {
|
yamlPart = '---\n' + jsyaml.dump( graph.yaml ) + '---\n';
|
||||||
dirPart = '%%{init: ' + JSON.stringify(graph.dir) + '}%%\n';
|
|
||||||
}
|
}
|
||||||
if (JSON.stringify(graph.yaml) !== '{}') {
|
var dirPart = '';
|
||||||
yamlPart = '---\n' + jsyaml.dump(graph.yaml) + '---\n';
|
if( Object.keys( graph.dir ).length ){
|
||||||
|
dirPart = '%%{init: ' + JSON.stringify( graph.dir ) + '}%%\n';
|
||||||
}
|
}
|
||||||
return yamlPart + dirPart + graph.content;
|
return yamlPart + dirPart + graph.content;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue