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 %} {%- if theme.mermaid.enable %}
<script{{ pjax }}> <script{{ pjax }}>
if (document.querySelectorAll('pre.mermaid').length) { if (document.querySelectorAll('.mermaid').length) {
NexT.utils.getScript('{{ theme.vendors.mermaid }}', () => { NexT.utils.getScript('{{ theme.vendors.mermaid }}', () => {
mermaid.init({ mermaid.init({
theme : '{{ theme.mermaid.theme }}', theme : '{{ theme.mermaid.theme }}',

View File

@ -7,8 +7,8 @@
const { escapeHTML } = require('hexo-util'); const { escapeHTML } = require('hexo-util');
module.exports = function(args, content) { module.exports = function(args, content) {
return `<pre class="mermaid" style="text-align: center;"> return `<div class="mermaid">
${args.join(' ')} ${args.join(' ')}
${escapeHTML(content)} ${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 'note' if (hexo-config('note.style') != 'disabled');
@import 'pdf' if (hexo-config('pdf.enable')); @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'); const mermaid = require('../../scripts/tags/mermaid');
it('default', () => { 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 graph TD
${escapeHTML(result)} ${escapeHTML(result)}
</pre>`); </div>`);
}); });
}); });