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
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
1"""
2Adds mermaid support to the page.
4"""
5from lcdoc.tools import read_file, dirname lp|features/lp/plugs/mermaid/index.md
6import html lp|features/lp/plugs/mermaid/index.md
8eval = "always" lp|features/lp/plugs/mermaid/index.md
10M = """
11<pre class="mermaid"><code>%s
12</code></pre>
13"""
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}
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