Action Directory / Mermaid & Single & Check

Install

select your mermaid graph definition
(e.g:
graph LR
a --> b
)
then run the script
you will get rendered graph preview if everything turns out to be right otherwise empty view
original project: https://github.com/knsv/mermaid

Shared by MinamotoYoi

Script

var selected = editor.getSelectedText();

if(!selected) {
	ui.alert('nothing seleted!');
	return;
}

var finalContent = '<div class="mermaid">\n' + selected + '\n</div>\n';

finalContent = '<!DOCTYPE html>\n<html>\n<head>\n	<title>mermaid</title>\n	<script src="https://unpkg.com/mermaid@8.0.0-rc.8/dist/mermaid.min.js"></script>\n	<script>mermaid.initialize({startOnLoad:true, theme:"dark"});</script>\n</head>\n<body style="background-color: black">\n' + finalContent + '</body>\n</html>';

webBrowser.loadHTML(finalContent);