Fix mermaid tag

This commit is contained in:
Mimi 2020-07-31 00:31:47 +08:00
parent 33723be6ad
commit 10b577cc7f
3 changed files with 8 additions and 4 deletions

View File

@ -3,13 +3,13 @@
<script{{ pjax }}>
if (document.querySelectorAll('pre.mermaid').length) {
NexT.utils.getScript('{{ url_for(mermaid_uri) }}', () => {
mermaid.initialize({
mermaid.init({
theme : '{{ theme.mermaid.theme }}',
logLevel : 3,
flowchart: { curve : 'linear' },
gantt : { axisFormat: '%m/%d/%Y' },
sequence : { actorMargin: 50 }
});
}, '.mermaid');
}, window.mermaid);
}
</script>

View File

@ -4,9 +4,11 @@
'use strict';
const { escapeHTML } = require('hexo-util');
module.exports = function(args, content) {
return `<pre class="mermaid" style="text-align: center;">
${args.join(' ')}
${content}
${escapeHTML(content)}
</pre>`;
};

View File

@ -2,6 +2,8 @@
require('chai').should();
const { escapeHTML } = require('hexo-util');
const result = `A[Hard] -->|Text| B(Round)
B --> C{Decision}
C -->|One| D[Result 1]
@ -13,7 +15,7 @@ describe('mermaid', () => {
it('default', () => {
mermaid(['graph', 'TD'], result).should.eql(`<pre class="mermaid" style="text-align: center;">
graph TD
${result}
${escapeHTML(result)}
</pre>`);
});
});