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

View File

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

View File

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