Coverage for src/lcdoc/mkdocs/lp/plugs/mermaid/__init__.py: 100.00%

Shortcuts on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

10 statements  

1""" 

2Adds mermaid support to the page. 

3 

4""" 

5from lcdoc.tools import read_file, dirname lp|features/lp/plugs/mermaid/index.md

6import html lp|features/lp/plugs/mermaid/index.md

7 

8eval = "always" lp|features/lp/plugs/mermaid/index.md

9 

10M = """ 

11<pre class="mermaid"><code>%s 

12</code></pre> 

13""" 

14 

15fn = dirname(__file__) + "/page.js" lp|features/lp/plugs/mermaid/index.md

16page_assets = { 

17 "footer": read_file(fn), # finds all .mermaid and renders them 

18 "header": {"script": "https://unpkg.com/mermaid@8.12.1/dist/mermaid.min.js"}, 

19} 

20 

21 

22def run(cmd, kw): lp|features/lp/plugs/mermaid/index.md

23 # cmd is the mermaid chart (lp body) 

24 h = html.escape(cmd) lp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.md

25 h = M % h lp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.md

26 return {"res": h, "formatted": True} lp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.mdlp|features/lp/plugs/mermaid/index.md