Skip to content

Commit

Permalink
Fix mermaid background color
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Aug 16, 2020
1 parent 8d57b6d commit 376d718
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion layout/_third-party/tags/mermaid.njk
Original file line number Diff line number Diff line change
@@ -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 }}',
Expand Down
4 changes: 2 additions & 2 deletions scripts/tags/mermaid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>`;
};
4 changes: 4 additions & 0 deletions source/css/_common/scaffolding/tags/mermaid.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.mermaid {
margin-bottom: 20px;
text-align: center;
}
2 changes: 2 additions & 0 deletions source/css/_common/scaffolding/tags/tags.styl
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
4 changes: 2 additions & 2 deletions test/tags/mermaid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>`);
});
});

0 comments on commit 376d718

Please sign in to comment.