mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-20 19:02:33 +00:00
Fix mermaid tag
This commit is contained in:
parent
33723be6ad
commit
10b577cc7f
4
layout/_third-party/tags/mermaid.njk
vendored
4
layout/_third-party/tags/mermaid.njk
vendored
@ -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>
|
||||||
|
|||||||
@ -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>`;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -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>`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user