2019-02-18 18:11:53 +00:00
|
|
|
const { shim } = require('lib/shim');
|
|
|
|
|
|
|
|
|
|
class MdToHtml_Mermaid {
|
|
|
|
|
|
|
|
|
|
name() {
|
|
|
|
|
return 'mermaid';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
processContent(renderedTokens, content, tagType) {
|
|
|
|
|
renderedTokens.push('<div class="mermaid">' + content + '</div>');
|
|
|
|
|
return renderedTokens;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extraCss() {
|
2019-02-28 00:21:40 +00:00
|
|
|
// Force a white background because the graphs can have various colours
|
|
|
|
|
// that may not be compatible with the current theme. Also make it
|
|
|
|
|
// inline-block so that the div is the same size as the content.
|
|
|
|
|
return '.mermaid { background-color: white; display:inline-block; }';
|
2019-02-18 18:11:53 +00:00
|
|
|
}
|
|
|
|
|
|
2019-02-27 23:38:50 +00:00
|
|
|
injectedJavaScript() {
|
2019-03-02 23:22:41 +00:00
|
|
|
const js = shim.injectedJs('mermaid');
|
|
|
|
|
return js ? js + '\n' + 'mermaid.init();' : '';
|
2019-02-27 23:38:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-02-18 18:11:53 +00:00
|
|
|
async loadAssets() {}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = MdToHtml_Mermaid;
|