Fix mermaid background color

This commit is contained in:
Mimi 2020-08-16 13:35:09 +08:00
parent 8d57b6d980
commit 376d71878f
5 changed files with 11 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{%- if theme.mermaid.enable %}
<script{{ pjax }}>
if (document.querySelectorAll('pre.mermaid').length) {
if (document.querySelectorAll('.mermaid').length) {
NexT.utils.getScript('{{ theme.vendors.mermaid }}', () => {
mermaid.init({
theme : '{{ theme.mermaid.theme }}',

View File

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

View File

@ -0,0 +1,4 @@
.mermaid {
margin-bottom: 20px;
text-align: center;
}

View File

@ -7,3 +7,5 @@
@import 'note' if (hexo-config('note.style') != 'disabled');
@import 'pdf' if (hexo-config('pdf.enable'));
@import 'mermaid' if (hexo-config('mermaid.enable'));

View File

@ -13,9 +13,9 @@ describe('mermaid', () => {
const mermaid = require('../../scripts/tags/mermaid');
it('default', () => {
mermaid(['graph', 'TD'], result).should.eql(`<pre class="mermaid" style="text-align: center;">
mermaid(['graph', 'TD'], result).should.eql(`<div class="mermaid">
graph TD
${escapeHTML(result)}
</pre>`);
</div>`);
});
});