-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collapsed admonitions does not display mermaid properly #8
Comments
Thank you for your contribution! This is very appreciated. |
This is interesting, since it is the first time someone reported testing the case of collapsible notes in combination with mermaid. Just to be sure, did you try this with mermaid2? It is now quite a different beast than the original plugin. It is hard to say if the problem is any of the two (admonition or mermaid2). The question might be "how are they interfering with each other, and what could be done to make them work together?" It would help if you showed a) markdown, b) raw HTML section (in the page served), c) HTML section after javascript execution, in each of the 4 cases:
I realize it's 12 items, but we would have a "scientific study", which would give us a pretty good picture... Also, which browser are you using? Just in case it could be a problem. |
Hi, yes, the reason I did it with mermaid2 is that the original plugin had the same problem. So here is the files. # Welcome to MkDocs
???+ note "Collapsable but open"
```mermaid
graph TD
A[Client] --> B[Load Balancer]
```
??? note "Collapsed"
```mermaid
graph TD
A[Client] --> B[Load Balancer]
``` site/index.htmlFrom mkdocs build <h1 id="welcome-to-mkdocs">Welcome to MkDocs</h1>
<details class="note" open="open"><summary>Collapsable but open</summary><div class="mermaid">graph TD
A[Client] --> B[Load Balancer]
</div>
</details>
<details class="note"><summary>Collapsed</summary><div class="mermaid">graph TD
A[Client] --> B[Load Balancer]
</div>
</details> output from mkdocs serveUsing Chrome Version 84.0.4147.135 - <details class="note" open="open">
? ----
+ <details class="note" open="">
? +
- <summary>Collapsable but open</summary>
? --- ^^^^^^^^^
+ <summary>Collapsed</summary>
? ^
- <div class="mermaid" data-processed="true"><svg id="mermaid-159781860xxxx" width="187.546875"
? ----- ---
+ <div class="mermaid" data-processed="true"><svg id="mermaid-159781860xxxx" width="16"
- xmlns="http://www.w3.org/2000/svg" height="181" viewBox="0 0 187.546875 181">
? ^^ ^^^ ----- --- ^^
+ xmlns="http://www.w3.org/2000/svg" height="16" viewBox="-8 -8 16 16">
? ^ ^^^^^ ^
<style>
#mermaid-159781860xxxx {
font-family: "trebuchet ms", verdana, arial;
font-size: 16px;
fill: #333;
}
#mermaid-159781860xxxx .error-icon {
fill: #552222;
}
#mermaid-159781860xxxx .error-text {
fill: #552222;
stroke: #552222;
}
#mermaid-159781860xxxx .edge-thickness-normal {
stroke-width: 2px;
}
#mermaid-159781860xxxx .edge-thickness-thick {
stroke-width: 3.5px;
}
#mermaid-159781860xxxx .edge-pattern-solid {
stroke-dasharray: 0;
}
#mermaid-159781860xxxx .edge-pattern-dashed {
stroke-dasharray: 3;
}
#mermaid-159781860xxxx .edge-pattern-dotted {
stroke-dasharray: 2;
}
#mermaid-159781860xxxx .marker {
fill: #333333;
}
#mermaid-159781860xxxx .marker.cross {
stroke: #333333;
}
#mermaid-159781860xxxx svg {
font-family: "trebuchet ms", verdana, arial;
font-size: 16px;
}
#mermaid-159781860xxxx .label {
font-family: "trebuchet ms", verdana, arial;
color: #333;
}
#mermaid-159781860xxxx .label text {
fill: #333;
}
#mermaid-159781860xxxx .node rect,
#mermaid-159781860xxxx .node circle,
#mermaid-159781860xxxx .node ellipse,
#mermaid-159781860xxxx .node polygon,
#mermaid-159781860xxxx .node path {
fill: #ECECFF;
stroke: #9370DB;
stroke-width: 1px;
}
#mermaid-159781860xxxx .node .label {
text-align: center;
}
#mermaid-159781860xxxx .node.clickable {
cursor: pointer;
}
#mermaid-159781860xxxx .arrowheadPath {
fill: #333333;
}
#mermaid-159781860xxxx .edgePath .path {
stroke: #333333;
stroke-width: 1.5px;
}
#mermaid-159781860xxxx .flowchart-link {
stroke: #333333;
fill: none;
}
#mermaid-159781860xxxx .edgeLabel {
background-color: #e8e8e8;
text-align: center;
}
#mermaid-159781860xxxx .edgeLabel rect {
opacity: 0.5;
background-color: #e8e8e8;
fill: #e8e8e8;
}
#mermaid-159781860xxxx .cluster rect {
fill: #ffffde;
stroke: #aaaa33;
stroke-width: 1px;
}
#mermaid-159781860xxxx .cluster text {
fill: #333;
}
#mermaid-159781860xxxx div.mermaidTooltip {
position: absolute;
text-align: center;
max-width: 200px;
padding: 2px;
font-family: "trebuchet ms", verdana, arial;
font-size: 12px;
background: hsl(80, 100%, 96.2745098039%);
border: 1px solid #aaaa33;
border-radius: 2px;
pointer-events: none;
z-index: 100;
}
#mermaid-159781860xxxx:root {
--mermaid-font-family: "trebuchet ms", verdana, arial;
}
#mermaid-159781860xxxx flowchart {
fill: apa;
}
</style>
<g>
<g class="output">
<g class="clusters"></g>
<g class="edgePaths">
<g class="edgePath LS-A LE-B" id="L-A-B" style="opacity: 1;">
- <path class="path" d="M93.7734375,65.5L93.7734375,90.5L93.7734375,115.5"
- marker-end="url(#arrowhead7)" style="fill:none"></path>
? ^^^ ^ -------
+ <path class="path" d="M8,8L8,33L8,58" marker-end="url(#arrowhead14)" style="fill:none">
? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^
+ </path>
<defs>
- <marker id="arrowhead7" viewBox="0 0 10 10" refX="9" refY="5"
? ^
+ <marker id="arrowhead14" viewBox="0 0 10 10" refX="9" refY="5"
? ^^
markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath"
style="stroke-width: 1; stroke-dasharray: 1, 0;"></path>
</marker>
</defs>
</g>
</g>
<g class="edgeLabels">
- <g class="edgeLabel" style="opacity: 1;" transform="">
? -------------
+ <g class="edgeLabel" transform="" style="opacity: 1;">
? +++++++++++++
<g transform="translate(0,0)" class="label">
<rect rx="0" ry="0" width="0" height="0"></rect>
<foreignObject width="0" height="0">
<div xmlns="http://www.w3.org/1999/xhtml"
style="display: inline-block; white-space: nowrap;"><span id="L-L-A-B"
class="edgeLabel L-LS-A' L-LE-B"></span></div>
</foreignObject>
</g>
</g>
</g>
<g class="nodes">
- <g class="node default" id="A" transform="translate(93.7734375,36.75)" style="opacity: 1;">
? ^^^^^^^^^^ ^^^^^
+ <g class="node default" id="A" transform="translate(8,8)" style="opacity: 1;">
? ^ ^
- <rect rx="0" ry="0" x="-42" y="-28.75" width="84" height="57.5" class="label-container">
? ^^ ^^^^^ ^^ ^^^^
+ <rect rx="0" ry="0" x="-10" y="-10" width="20" height="20" class="label-container">
? ^^ ^^ ^^ ^^
</rect>
<g class="label" transform="translate(0,0)">
- <g transform="translate(-32,-18.75)">
? ^^^ ^^^^^^
+ <g transform="translate(0,0)">
? ^ ^
- <foreignObject width="64.0078125" height="37.5">
? --- ------ ^^^^
+ <foreignObject width="0" height="0">
? ^
<div xmlns="http://www.w3.org/1999/xhtml"
style="display: inline-block; white-space: nowrap;">Client</div>
</foreignObject>
</g>
</g>
</g>
- <g class="node default" id="B" transform="translate(93.7734375,144.25)" style="opacity: 1;">
? ^^^^^^^^^ ^^^^^^^
+ <g class="node default" id="B" transform="translate(8,58)" style="opacity: 1;">
? ^^ ^
- <rect rx="0" ry="0" x="-85.7734375" y="-28.75" width="171.546875" height="57.5"
- class="label-container"></rect>
+ <rect rx="0" ry="0" x="-10" y="-10" width="20" height="20" class="label-container">
+ </rect>
<g class="label" transform="translate(0,0)">
- <g transform="translate(-75.7734375,-18.75)">
? ^^^^^^^^^^^ ^^^^^^
+ <g transform="translate(0,0)">
? ^ ^
- <foreignObject width="151.546875" height="37.5">
? ^^^^^^^^^^ ^^^^
+ <foreignObject width="0" height="0">
? ^ ^
<div xmlns="http://www.w3.org/1999/xhtml"
style="display: inline-block; white-space: nowrap;">Load Balancer</div>
</foreignObject>
</g>
</g>
</g>
</g>
</g>
</g>
</svg></div> pip freeze
mkdocs.yamlsite_name: My Docs
plugins:
- search
- mermaid2
extra_javascript:
- https://unpkg.com/mermaid/dist/mermaid.min.js
theme:
name: material
markdown_extensions:
- admonition
- pymdownx.details
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:mermaid2.fence_mermaid |
Sorry, read through your comment again. I will setup the 4 cases later today. |
Ok, hopefully I understood what you ment. I am using Chrome v. 84.0.4147.135 Setuppip freeze
mkdocs.yamlsite_name: My Docs
plugins:
- search
- mermaid2
extra_javascript:
- https://unpkg.com/mermaid/dist/mermaid.min.js
theme:
name: material
markdown_extensions:
- admonition
- pymdownx.details
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:mermaid2.fence_mermaid So here is the cases. 1 Without the admonition plugin1a docs/case1.md ```mermaid
graph TD
A[Client] --> B[Load Balancer]
``` 1b site/case1/index.htmlFrom mkdocs build <div class="mermaid">graph TD
A[Client] --> B[Load Balancer]
</div> 1c output after js<div class="mermaid" data-processed="true"><svg id="mermaid-1597821871135" width="187.546875"
xmlns="http://www.w3.org/2000/svg" height="181" viewBox="0 0 187.546875 181">
<style>
#mermaid-1597821871135 {
font-family: "trebuchet ms", verdana, arial;
font-size: 16px;
fill: #333;
}
#mermaid-1597821871135 .error-icon {
fill: #552222;
}
#mermaid-1597821871135 .error-text {
fill: #552222;
stroke: #552222;
}
#mermaid-1597821871135 .edge-thickness-normal {
stroke-width: 2px;
}
#mermaid-1597821871135 .edge-thickness-thick {
stroke-width: 3.5px;
}
#mermaid-1597821871135 .edge-pattern-solid {
stroke-dasharray: 0;
}
#mermaid-1597821871135 .edge-pattern-dashed {
stroke-dasharray: 3;
}
#mermaid-1597821871135 .edge-pattern-dotted {
stroke-dasharray: 2;
}
#mermaid-1597821871135 .marker {
fill: #333333;
}
#mermaid-1597821871135 .marker.cross {
stroke: #333333;
}
#mermaid-1597821871135 svg {
font-family: "trebuchet ms", verdana, arial;
font-size: 16px;
}
#mermaid-1597821871135 .label {
font-family: "trebuchet ms", verdana, arial;
color: #333;
}
#mermaid-1597821871135 .label text {
fill: #333;
}
#mermaid-1597821871135 .node rect,
#mermaid-1597821871135 .node circle,
#mermaid-1597821871135 .node ellipse,
#mermaid-1597821871135 .node polygon,
#mermaid-1597821871135 .node path {
fill: #ECECFF;
stroke: #9370DB;
stroke-width: 1px;
}
#mermaid-1597821871135 .node .label {
text-align: center;
}
#mermaid-1597821871135 .node.clickable {
cursor: pointer;
}
#mermaid-1597821871135 .arrowheadPath {
fill: #333333;
}
#mermaid-1597821871135 .edgePath .path {
stroke: #333333;
stroke-width: 1.5px;
}
#mermaid-1597821871135 .flowchart-link {
stroke: #333333;
fill: none;
}
#mermaid-1597821871135 .edgeLabel {
background-color: #e8e8e8;
text-align: center;
}
#mermaid-1597821871135 .edgeLabel rect {
opacity: 0.5;
background-color: #e8e8e8;
fill: #e8e8e8;
}
#mermaid-1597821871135 .cluster rect {
fill: #ffffde;
stroke: #aaaa33;
stroke-width: 1px;
}
#mermaid-1597821871135 .cluster text {
fill: #333;
}
#mermaid-1597821871135 div.mermaidTooltip {
position: absolute;
text-align: center;
max-width: 200px;
padding: 2px;
font-family: "trebuchet ms", verdana, arial;
font-size: 12px;
background: hsl(80, 100%, 96.2745098039%);
border: 1px solid #aaaa33;
border-radius: 2px;
pointer-events: none;
z-index: 100;
}
#mermaid-1597821871135:root {
--mermaid-font-family: "trebuchet ms", verdana, arial;
}
#mermaid-1597821871135 flowchart {
fill: apa;
}
</style>
<g>
<g class="output">
<g class="clusters"></g>
<g class="edgePaths">
<g class="edgePath LS-A LE-B" id="L-A-B" style="opacity: 1;">
<path class="path" d="M93.7734375,65.5L93.7734375,90.5L93.7734375,115.5"
marker-end="url(#arrowhead7)" style="fill:none"></path>
<defs>
<marker id="arrowhead7" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth"
markerWidth="8" markerHeight="6" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath"
style="stroke-width: 1; stroke-dasharray: 1, 0;"></path>
</marker>
</defs>
</g>
</g>
<g class="edgeLabels">
<g class="edgeLabel" style="opacity: 1;" transform="">
<g transform="translate(0,0)" class="label">
<rect rx="0" ry="0" width="0" height="0"></rect>
<foreignObject width="0" height="0">
<div xmlns="http://www.w3.org/1999/xhtml"
style="display: inline-block; white-space: nowrap;"><span id="L-L-A-B"
class="edgeLabel L-LS-A' L-LE-B"></span></div>
</foreignObject>
</g>
</g>
</g>
<g class="nodes">
<g class="node default" id="A" transform="translate(93.7734375,36.75)" style="opacity: 1;">
<rect rx="0" ry="0" x="-42" y="-28.75" width="84" height="57.5" class="label-container"></rect>
<g class="label" transform="translate(0,0)">
<g transform="translate(-32,-18.75)">
<foreignObject width="64.0078125" height="37.5">
<div xmlns="http://www.w3.org/1999/xhtml"
style="display: inline-block; white-space: nowrap;">Client</div>
</foreignObject>
</g>
</g>
</g>
<g class="node default" id="B" transform="translate(93.7734375,144.25)" style="opacity: 1;">
<rect rx="0" ry="0" x="-85.7734375" y="-28.75" width="171.546875" height="57.5"
class="label-container"></rect>
<g class="label" transform="translate(0,0)">
<g transform="translate(-75.7734375,-18.75)">
<foreignObject width="151.546875" height="37.5">
<div xmlns="http://www.w3.org/1999/xhtml"
style="display: inline-block; white-space: nowrap;">Load Balancer</div>
</foreignObject>
</g>
</g>
</g>
</g>
</g>
</g>
</svg></div> ##2 2a docs/index.md
2b site/case2/index.html<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Just a note</p>
</div> 2c output after js<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Just a note</p>
</div> 3 Collapsible open3a docs/case3.md???+ note "Collapsible open"
```mermaid
graph TD
A[Client] --> B[Load Balancer]
``` 3b site/case3/index.html<details class="note" open="open"><summary>Collapsible open</summary><div class="mermaid">graph TD
A[Client] --> B[Load Balancer]
</div> 3c output after js<details class="note" open="open">
<summary>Collapsible open</summary>
<div class="mermaid" data-processed="true"><svg id="mermaid-1597822260940" width="187.546875"
xmlns="http://www.w3.org/2000/svg" height="181" viewBox="0 0 187.546875 181">
<style>
#mermaid-1597822260940 {
font-family: "trebuchet ms", verdana, arial;
font-size: 16px;
fill: #333;
}
#mermaid-1597822260940 .error-icon {
fill: #552222;
}
#mermaid-1597822260940 .error-text {
fill: #552222;
stroke: #552222;
}
#mermaid-1597822260940 .edge-thickness-normal {
stroke-width: 2px;
}
#mermaid-1597822260940 .edge-thickness-thick {
stroke-width: 3.5px;
}
#mermaid-1597822260940 .edge-pattern-solid {
stroke-dasharray: 0;
}
#mermaid-1597822260940 .edge-pattern-dashed {
stroke-dasharray: 3;
}
#mermaid-1597822260940 .edge-pattern-dotted {
stroke-dasharray: 2;
}
#mermaid-1597822260940 .marker {
fill: #333333;
}
#mermaid-1597822260940 .marker.cross {
stroke: #333333;
}
#mermaid-1597822260940 svg {
font-family: "trebuchet ms", verdana, arial;
font-size: 16px;
}
#mermaid-1597822260940 .label {
font-family: "trebuchet ms", verdana, arial;
color: #333;
}
#mermaid-1597822260940 .label text {
fill: #333;
}
#mermaid-1597822260940 .node rect,
#mermaid-1597822260940 .node circle,
#mermaid-1597822260940 .node ellipse,
#mermaid-1597822260940 .node polygon,
#mermaid-1597822260940 .node path {
fill: #ECECFF;
stroke: #9370DB;
stroke-width: 1px;
}
#mermaid-1597822260940 .node .label {
text-align: center;
}
#mermaid-1597822260940 .node.clickable {
cursor: pointer;
}
#mermaid-1597822260940 .arrowheadPath {
fill: #333333;
}
#mermaid-1597822260940 .edgePath .path {
stroke: #333333;
stroke-width: 1.5px;
}
#mermaid-1597822260940 .flowchart-link {
stroke: #333333;
fill: none;
}
#mermaid-1597822260940 .edgeLabel {
background-color: #e8e8e8;
text-align: center;
}
#mermaid-1597822260940 .edgeLabel rect {
opacity: 0.5;
background-color: #e8e8e8;
fill: #e8e8e8;
}
#mermaid-1597822260940 .cluster rect {
fill: #ffffde;
stroke: #aaaa33;
stroke-width: 1px;
}
#mermaid-1597822260940 .cluster text {
fill: #333;
}
#mermaid-1597822260940 div.mermaidTooltip {
position: absolute;
text-align: center;
max-width: 200px;
padding: 2px;
font-family: "trebuchet ms", verdana, arial;
font-size: 12px;
background: hsl(80, 100%, 96.2745098039%);
border: 1px solid #aaaa33;
border-radius: 2px;
pointer-events: none;
z-index: 100;
}
#mermaid-1597822260940:root {
--mermaid-font-family: "trebuchet ms", verdana, arial;
}
#mermaid-1597822260940 flowchart {
fill: apa;
}
</style>
<g>
<g class="output">
<g class="clusters"></g>
<g class="edgePaths">
<g class="edgePath LS-A LE-B" id="L-A-B" style="opacity: 1;">
<path class="path" d="M93.7734375,65.5L93.7734375,90.5L93.7734375,115.5" marker-end="url(#arrowhead7)"
style="fill:none"></path>
<defs>
<marker id="arrowhead7" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8"
markerHeight="6" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath"
style="stroke-width: 1; stroke-dasharray: 1, 0;"></path>
</marker>
</defs>
</g>
</g>
<g class="edgeLabels">
<g class="edgeLabel" style="opacity: 1;" transform="">
<g transform="translate(0,0)" class="label">
<rect rx="0" ry="0" width="0" height="0"></rect>
<foreignObject width="0" height="0">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span
id="L-L-A-B" class="edgeLabel L-LS-A' L-LE-B"></span></div>
</foreignObject>
</g>
</g>
</g>
<g class="nodes">
<g class="node default" id="A" transform="translate(93.7734375,36.75)" style="opacity: 1;">
<rect rx="0" ry="0" x="-42" y="-28.75" width="84" height="57.5" class="label-container"></rect>
<g class="label" transform="translate(0,0)">
<g transform="translate(-32,-18.75)">
<foreignObject width="64.0078125" height="37.5">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;">Client
</div>
</foreignObject>
</g>
</g>
</g>
<g class="node default" id="B" transform="translate(93.7734375,144.25)" style="opacity: 1;">
<rect rx="0" ry="0" x="-85.7734375" y="-28.75" width="171.546875" height="57.5" class="label-container">
</rect>
<g class="label" transform="translate(0,0)">
<g transform="translate(-75.7734375,-18.75)">
<foreignObject width="151.546875" height="37.5">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;">Load
Balancer</div>
</foreignObject>
</g>
</g>
</g>
</g>
</g>
</g>
</svg></div>
</details> 4 Collapsible closed4a docs/case4.md??? note "Collapsible closed"
```mermaid
graph TD
A[Client] --> B[Load Balancer]
``` 4b site/case4/index.html<h1>Case4</h1>
<details class="note"><summary>Collapsible closed</summary><div class="mermaid">graph TD
A[Client] --> B[Load Balancer]
</div> 4c output after js<details class="note">
<summary>Collapsible closed</summary>
<div class="mermaid" data-processed="true"><svg id="mermaid-1597822423940" width="16"
xmlns="http://www.w3.org/2000/svg" height="16" viewBox="-8 -8 16 16">
<style>
#mermaid-1597822423940 {
font-family: "trebuchet ms", verdana, arial;
font-size: 16px;
fill: #333;
}
#mermaid-1597822423940 .error-icon {
fill: #552222;
}
#mermaid-1597822423940 .error-text {
fill: #552222;
stroke: #552222;
}
#mermaid-1597822423940 .edge-thickness-normal {
stroke-width: 2px;
}
#mermaid-1597822423940 .edge-thickness-thick {
stroke-width: 3.5px;
}
#mermaid-1597822423940 .edge-pattern-solid {
stroke-dasharray: 0;
}
#mermaid-1597822423940 .edge-pattern-dashed {
stroke-dasharray: 3;
}
#mermaid-1597822423940 .edge-pattern-dotted {
stroke-dasharray: 2;
}
#mermaid-1597822423940 .marker {
fill: #333333;
}
#mermaid-1597822423940 .marker.cross {
stroke: #333333;
}
#mermaid-1597822423940 svg {
font-family: "trebuchet ms", verdana, arial;
font-size: 16px;
}
#mermaid-1597822423940 .label {
font-family: "trebuchet ms", verdana, arial;
color: #333;
}
#mermaid-1597822423940 .label text {
fill: #333;
}
#mermaid-1597822423940 .node rect,
#mermaid-1597822423940 .node circle,
#mermaid-1597822423940 .node ellipse,
#mermaid-1597822423940 .node polygon,
#mermaid-1597822423940 .node path {
fill: #ECECFF;
stroke: #9370DB;
stroke-width: 1px;
}
#mermaid-1597822423940 .node .label {
text-align: center;
}
#mermaid-1597822423940 .node.clickable {
cursor: pointer;
}
#mermaid-1597822423940 .arrowheadPath {
fill: #333333;
}
#mermaid-1597822423940 .edgePath .path {
stroke: #333333;
stroke-width: 1.5px;
}
#mermaid-1597822423940 .flowchart-link {
stroke: #333333;
fill: none;
}
#mermaid-1597822423940 .edgeLabel {
background-color: #e8e8e8;
text-align: center;
}
#mermaid-1597822423940 .edgeLabel rect {
opacity: 0.5;
background-color: #e8e8e8;
fill: #e8e8e8;
}
#mermaid-1597822423940 .cluster rect {
fill: #ffffde;
stroke: #aaaa33;
stroke-width: 1px;
}
#mermaid-1597822423940 .cluster text {
fill: #333;
}
#mermaid-1597822423940 div.mermaidTooltip {
position: absolute;
text-align: center;
max-width: 200px;
padding: 2px;
font-family: "trebuchet ms", verdana, arial;
font-size: 12px;
background: hsl(80, 100%, 96.2745098039%);
border: 1px solid #aaaa33;
border-radius: 2px;
pointer-events: none;
z-index: 100;
}
#mermaid-1597822423940:root {
--mermaid-font-family: "trebuchet ms", verdana, arial;
}
#mermaid-1597822423940 flowchart {
fill: apa;
}
</style>
<g>
<g class="output">
<g class="clusters"></g>
<g class="edgePaths">
<g class="edgePath LS-A LE-B" id="L-A-B" style="opacity: 1;">
<path class="path" d="M8,8L8,33L8,58" marker-end="url(#arrowhead7)" style="fill:none"></path>
<defs>
<marker id="arrowhead7" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8"
markerHeight="6" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath"
style="stroke-width: 1; stroke-dasharray: 1, 0;"></path>
</marker>
</defs>
</g>
</g>
<g class="edgeLabels">
<g class="edgeLabel" transform="" style="opacity: 1;">
<g transform="translate(0,0)" class="label">
<rect rx="0" ry="0" width="0" height="0"></rect>
<foreignObject width="0" height="0">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span
id="L-L-A-B" class="edgeLabel L-LS-A' L-LE-B"></span></div>
</foreignObject>
</g>
</g>
</g>
<g class="nodes">
<g class="node default" id="A" transform="translate(8,8)" style="opacity: 1;">
<rect rx="0" ry="0" x="-10" y="-10" width="20" height="20" class="label-container"></rect>
<g class="label" transform="translate(0,0)">
<g transform="translate(0,0)">
<foreignObject width="0" height="0">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;">Client
</div>
</foreignObject>
</g>
</g>
</g>
<g class="node default" id="B" transform="translate(8,58)" style="opacity: 1;">
<rect rx="0" ry="0" x="-10" y="-10" width="20" height="20" class="label-container"></rect>
<g class="label" transform="translate(0,0)">
<g transform="translate(0,0)">
<foreignObject width="0" height="0">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;">Load
Balancer</div>
</foreignObject>
</g>
</g>
</g>
</g>
</g>
</g>
</svg></div>
</details> |
Wow, thank's a lot! I cross-referenced the issue on the mkdocs-material repo, as this may be an interaction issue. |
See answer from the maintainer of the material project : |
Sorry, I responded in the wrong issue. |
Actually it's even better :-) I am tracking: you set |
Yes, I'm basically handling the load myself by disabling it and using my own. I render the content under a parent of my choice and then replace the original content. There may or may not be subtle differences. While I source the payload from pre/code tags, the same concept works when applied to Mermaid's default expectation of div tags. |
@facelessuser What would you have in your mkdocs.yml? Something like this:
With the Another question would be: is there an elegant way to keep aligned with your versions of these javascript directories ? 🤔 |
Mermaid has to load first, config next, and lastly the loader. Now, I load both the Mermaid library and the config at the foot of the page I intend to have UMLs on (via the Snippets extension). I do this to avoid loading heavy JS libraries that I only actually need on a few pages. But if I were loading them in all pages, I'd probably setup the config in my extra.js before I call the loader, and include mermaid before I include my extra.js. I'm not sure what the best way to sync up would be. |
Currently, all our extra.js does is UML stuff, but that is not guaranteed to be the case forever. If something I wish to include in the future catches my eye, then I may update extra to do more. The Maybe if I get some time, I can play with your plugin a bit, and see if there is an easy way to get yours doing what I do. Something fairly easy for you to maintain. |
@AndersSteenNilsen I've got a strange behavior. I use:
The first graph displays properly, but second one actually gives me an... error when I uncollapse, even though the initial code identical. It's not what you observe? |
Hmm. I may have to update things for 8.6.4. Things have changed.... |
@facelessuser I've not used your code yet for this test, so perhaps it's perfectly OK? |
I just get a tiny image for the closed one on Mermaid-js 8.7.0. Themeing also broke 😭. I'll have to look into all of this again. The small SVG is most likely because I need to render it under some different element. Pretty sure I had this right at one point... |
😕 Let's try to backtrack a little. Which version of the library works for you, so at least we have a working approach for the moment? |
It works in
|
I'm thinking maybe some styling with MkDocs threw off the size the diagrams in hidden elements, because I'm positive I had this working in 8.4.8... |
I have them rendering in 8.7.0 now. I'll have to revisit themeing as they totally rewrote all of that. |
Here's my current fix: facelessuser/pymdown-extensions@2777e81 |
@fralau, last of my fixes are in. Got themes working again (albeit couldn't get everything exactly the same, but 🤷). The official docs are now running 8.7.0, and I verified it works in Details and Tabs. |
@facelessuser Thanks a lot for the quick response ! Now is my turn to attempt to package those fixes in the plugin... What seemed initially a simple, "no-brainer" plugin is getting increasingly more sophisticated. 🙂 |
Wow. I'm a little flustered. Default situation: At least I realized that the dot appears in Chrome and Safari, but not in Firefox, which seems to start the mermaid script, but to create an error... So behavior varies across browsers. I'm trying to get a setup that works with @facelessuser's solution. I set up
And the two files, I get that error in the browser's console: This is swampy terrain. Am I far away from the target or close? I don't know. |
I don't know what's in your loader. |
I think I may have mentioned this before, but I compile my code source into one file I imagine you tried to grab the source directly and try it? This is the actual compiled source before compressing it. This is what you should use as it is what babel spits out when it is done. You can edit this one to your liking. (function () {
'use strict';
/**
* Targets special code or div blocks and converts them to UML.
* @param {string} className is the name of the class to target.
* @return {void}
*/
var uml = (function (className) {
// Themes themes 99% of what we want, but there are still some stubborn things that require CSS
// `https://github.com/facelessuser/pymdown-extensions/blob/master/docs/src/scss/js/_mermaid_dracula.scss`
var configDark = {
startOnLoad: false,
theme: "base",
themeVariables: {
darkMode: true,
background: "#323443",
mainBkg: "#604b7d",
textColor: "#bf95f9",
lineColor: "#bf95f9",
errorBkgColor: "#802c2c",
errorTextColor: "#ff5757",
primaryColor: "#604b7d",
primaryTextColor: "#bf95f9",
primaryBorderColor: "#bf95f9",
secondaryColor: "#297d3e",
secondaryTextColor: "#52fa7c",
secondaryBorderColor: "#52fa7c",
tertiaryColor: "#303952",
tertiaryTextColor: "#6071a4",
tertiaryBorderColor: "#6071a4",
noteBkgColor: "#797d45",
noteTextColor: "#f1fa89",
noteBorderColor: "#f1fa89",
edgeLabelBackground: "#604b7d",
edgeLabelText: "#604b7d",
actorLineColor: "#6071a4",
activeTaskBkgColor: "#803d63",
activeTaskBorderColor: "#ff7ac6",
doneTaskBkgColor: "#297d3e",
doneTaskBorderColor: "#52fa7c",
critBkgColor: "#802c2c",
critBorderColor: "#ff5757",
taskTextColor: "#bf95f9",
taskTextOutsideColor: "#bf95f9",
taskTextLightColor: "#bf95f9",
sectionBkgColor: "#bf95f9b3",
sectionBkgColor2: "#bf95f966",
altSectionBkgColor: "#323443",
todayLineColor: "#ff7ac6",
gridColor: "#6071a4",
defaultLinkColor: "#8be8fd",
altBackground: "#bf95f9",
classText: "#bf95f9",
fillType0: "#406080",
fillType1: "#46747f",
fillType2: "#297d3e",
fillType3: "#805c36",
fillType4: "#803d63",
fillType5: "#604b7d",
fillType6: "#802c2c",
fillType7: "#797d45",
fillType8: "#7c7c79"
},
flowchart: {
htmlLabels: false
},
sequence: {
useMaxWidth: false
},
"class": {
textHeight: 16,
dividerMargin: 16
}
};
var configLight = {
startOnLoad: false,
theme: "base",
flowchart: {
htmlLabels: false
},
sequence: {
useMaxWidth: false
},
"class": {
textHeight: 16,
dividerMargin: 16
}
};
var getFromCode = function getFromCode(parent) {
// Handles <pre><code> text extraction.
var text = "";
for (var j = 0; j < parent.childNodes.length; j++) {
var subEl = parent.childNodes[j];
if (subEl.tagName.toLowerCase() === "code") {
for (var k = 0; k < subEl.childNodes.length; k++) {
var child = subEl.childNodes[k];
var whitespace = /^\s*$/;
if (child.nodeName === "#text" && !whitespace.test(child.nodeValue)) {
text = child.nodeValue;
break;
}
}
}
}
return text;
}; // Get the proper theme color
if (document.querySelector("[data-md-color-primary^=\"drac-\"]")) {
mermaid.initialize(configDark);
} else {
mermaid.initialize(configLight);
} // Find all of our Mermaid sources and render them.
var config = mermaid.mermaidAPI.getConfig();
var blocks = document.querySelectorAll("pre.".concat(className));
var surogate = document.querySelector("html");
var _loop = function _loop(i) {
var parentEl = blocks[i]; // Create a temporary element with the typeset and size we desire.
// Insert it at the end of our parent to render the SVG.
var temp = document.createElement("div");
temp.style.visibility = "hidden";
temp.style.width = "100%";
temp.style.minWidth = "100%";
temp.style.fontSize = config.themeVariables.fontSize || "16px";
surogate.appendChild(temp);
mermaid.mermaidAPI.render("_mermaind_".concat(i), getFromCode(parentEl), function (content) {
var el = document.createElement("div");
el.className = className;
el.innerHTML = content;
var child = el.childNodes[0]; // Some mermaid items have no height assigned, fix this for sane sizes. Mainly for state diagrams.
//
// Notes (as of Mermaid 8.4.8):
// - Gantt: width is always relative to the parent, if you have a small parent, the chart will be squashed.
// Can't help it.
// - Pie: These charts have no default height or width. Good luck pinning them down to a reasonable size.
// - Git: The render portion is agnostic to the size of the parent element. But padding of the SVG is relative
// to the parent element. You will never find a happy size.
// - State/Class: These two are rendered with references internally in the SVG that certain elements link to.
// The problem is that they link to internal elements that use the same IDs that are in other sibling SVG
// of these types. All other diagrams use unique IDs. So if the first of these gets hidden due to being in an
// inactive tab, or hidden under a closed details element the browser will not be able to find the ID as it
// only searches for the first. This will cause certain visual elements (arrow heads etc.) to disappear.
if (!child.hasAttribute("height") && child.hasAttribute("width")) {
child.setAttribute("height", temp.childNodes[0].getBoundingClientRect().height);
} // Insert the render where we want it and remove the original text source.
// Mermaid will clean up the temporary element.
parentEl.parentNode.insertBefore(el, parentEl);
parentEl.parentNode.removeChild(parentEl);
}, temp);
};
for (var i = 0; i < blocks.length; i++) {
_loop(i);
}
});
(function () {
var onReady = function onReady(fn) {
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", fn);
document.addEventListener("DOMContentSwitch", fn);
} else {
document.attachEvent("onreadystatechange", function () {
if (document.readyState === "interactive") {
fn();
}
});
}
};
onReady(function () {
if (typeof mermaid !== "undefined") {
uml("mermaid");
}
});
})();
}()); Then all you have to do is include |
Also, do prepare yourself, for when you run into this issue. mermaid-js/mermaid#1318 This stems from them (in certain diagram types) using the same ID (non-unique IDs) for certain What this means is that if you hide the first diagram of that uses the same What they need to do is namespace their IDs to reduce the chance of people accidentally reusing those IDs, and secondly, use unique IDs for each diagram (increment some kind of counter or something every time they attempt to use an already used ID). Mermaid, while powerful, isn't without some hiccups. |
My loader looks for classes on |
Oh this was so simple. Sometime small mistakes can have vast consequences 👍 |
Yeah, I had already tested in a bare bones mkdocs project, so I knew the issue had to be specific to what you are doing, it's just hard to debug without seeing the code. So, seeing what you are doing made it easy. |
@facelessuser Alas 😢 on that test repo, I am still having problems
|
@facelessuser By the way, would you be in a position to provide a permalink for your mermaid loader library, e.g. by distributing it through npm/unpkg? |
@facelessuser I updated the project on github and pypi to facilitate testing (a The custom loader mode is alpha (semi-working). It activates only if two conditions are cumulatively met in the config file:
|
Two things I discovered:
|
This would probably be too much work for me. I'm not familiar with the process, and as you are starting to see, what you need differs a bit from what I need. |
Also, it may be good to change to this in the loader. The shadow DOM needs to be styled as block, and I found setting the initial line height helps any weird cutoff as well. style.textContent = ":host {display: block; line-height: initial;} div.mermaid {margin: 0; overflow: visible;}"; |
I updated my script with all the above changes accept reading loose HTML blocks. I also added a try/catch so that if one diagram fails, we also keep parsing the others. I also clean up temp divs. I thought at one point Mermaid cleaned those up automatically, but it appears that maybe it doesn't...maybe I imagined it 🤷. |
I will take it on myself to look for a solution for publishing the library and propose it to you. Trying is the least that I can do, after all your efforts. I'm afraid that my knowledge of css and javascript is not very deep (I'm far more comfortable with Python)... in which way do the needs of the plugin differ from your usual cases? Would you see a way to reconcile the plugin a little more with your view of things? |
One thing I'd like to avoid is having to support this work. I support a number of projects, and adding yet another one, especially one like loading Mermaid, which requires some fancy workarounds for issues that should have already been fixed in the main library, just isn't attractive to me. It's one of the reasons why I am just documenting the work I've done and then saying "have at it, you are on your own". I don't mind spending some time on it when I'm motivated, but having other projects depending on my work directly, with the expectation that I'm going to promptly fix those issues is not currently a road I want to go down. I'm also much more comfortable with Python, though I've taught myself a lot about front end web stuff. |
I was looking into It fails in 8.7.0, because there is a bug: mermaid-js/mermaid#1607. So, basically, what I have currently works all by itself. Here we have two blocks, one with HTML labels disabled and one with HTML labels enabled. I have securityLevel set to "loose"
With 8.7.0, it breaks due to the bug: So I think that all your package has to do now is just handle the yaml stuff and include the loader. 8.7.0 is not our concern as Mermaid needs to fix it in their next release. |
@facelessuser I should have pointed out this bug of 8.7.0 more clearly (mermaid-js/mermaid#1607). Mermaid's team are going to fix it, but that's the reason why I had to introduce this management of versions in my files. That was the reason why I deliberately used 8.6.4.
You're right about this. To me, Mermaid has also been a side project (I just took over the project because I wanted to fix something and it was no longer maintained). Also, as I said, I'm not expert with javascript and css. Here are my takeaways:
Clearly, you and I spent an inordinate amount of time. What we got out of it is useful experience 🙂 |
Perhaps the best thing is that we feed this work back upstream to Mermaid's project. I will
Hopefully it might have some value for them, and encourage some cross-pollination? |
I've already fed the most of it up to Mermaid. I have an open issue that goes into details about the IDs, and I've mentioned that wrapping things in shadow DOMs fixes it. What they do with it is up to them. As far as I'm concerned, the loader is now probably more robust than its ever been before. Hopefully, I don't have to touch it for a while, but time will tell 🙂 . |
Oh, perfect: just give me the link, I will have a look at it! In the event, I will refer to it if I open my own issue. |
I referenced it earlier in the thread: mermaid-js/mermaid#1318. It's probably my biggest complaint. That and the loader not rendering properly if it's in a details or something similar. Now that I've finally worked around all of that, I'm pretty happy. Maybe one day I won't have to around that stuff. |
Agreed. Sorry for missing your reference about the issue. It's the same as with version 8.6.4: you and I produced so much text in this thread that we both have trouble keeping up with each other 😄 |
- convert tags from <pre><code class='mermaid'> to <div><class='mermaid> as this is more robust. - amend documentation (use of superfences is no longer required) - documented (in Troubleshooting) the use of mermaid2.fence_mermaid_custom as experimental (to fix issue #8). - bump default mermaid lib version from 8.6.4 to 8.8.0, since the bug with rich text diagrams/hyperlinks in 8.7.0 has been fixed (see mermaid-js/mermaid#1607)
This issue is fixed in 9557eed (v. 0.5.0). This has been tested in the project in This is an experimental fix, which requires the use of @facelessuser's javascript loader (see instructions in README). Unless there are observations, this issue will be closed. |
@AndersSteenNilsen To make it clear, the collapsed "admonition" now works correctly with the diagram, providing one follows the instructions. |
Thank you for resolving this issue! @fralau, @facelessuser |
Do not know if this problem is in this plugin or in admonitions. But collapsible admonitions (that are already closed) only shows a small rectangle.
HTML output
I'm no expert in HTML, but I believe the main problem is the size.
Output for the two last examples:
PS: Tried this with the original plugin and it didn't work.
The text was updated successfully, but these errors were encountered: