diff options
| author | s-ol <s+removethis@s-ol.nu> | 2022-03-28 13:58:08 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2022-03-28 14:24:26 +0000 |
| commit | 269d9986c12e277eb6fd5241f34c027c439f84ae (patch) | |
| tree | 748f965272ada1293b5d5f12420f9f7cb069c0fa /root/$mmm/plugins/mermaid | |
| parent | move layout into user content (diff) | |
| download | mmm-269d9986c12e277eb6fd5241f34c027c439f84ae.tar.gz mmm-269d9986c12e277eb6fd5241f34c027c439f84ae.zip | |
fix plugins in example root
Diffstat (limited to 'root/$mmm/plugins/mermaid')
| -rw-r--r-- | root/$mmm/plugins/mermaid/converts: text$lua -> table.lua | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/root/$mmm/plugins/mermaid/converts: text$lua -> table.lua b/root/$mmm/plugins/mermaid/converts: text$lua -> table.lua new file mode 100644 index 0000000..1ed7787 --- /dev/null +++ b/root/$mmm/plugins/mermaid/converts: text$lua -> table.lua @@ -0,0 +1,32 @@ +if not (window and window.mermaid) then + return +end +window.mermaid:initialize({ + startOnLoad = false, + fontFamily = 'monospace' +}) +local id_counter = 1 +return { + { + inp = 'text/mermaid-graph', + out = 'mmm/dom', + cost = 1, + transform = function(self, source, fileder, key) + id_counter = id_counter + 1 + local id = "mermaid-" .. tostring(id_counter) + do + local container = document:createElement('div') + local cb + cb = function(self, svg) + container.innerHTML = svg + container.firstElementChild.style.width = '100%' + container.firstElementChild.style.height = 'auto' + end + window:setImmediate(function(_) + return window.mermaid:render(id, source, cb, container) + end) + return container + end + end + } +} |
