ioos / mbon-docs

MBON portal documentation
https://ioos.github.io/mbon-docs/
Other
0 stars 5 forks source link

Syntax error with mermaid diagram on data flow page #58

Closed MathewBiddle closed 23 hours ago

MathewBiddle commented 1 month ago

See https://ioos.github.io/mbon-docs/mbon-data-flow.html

image

I made a recent change to more easily incorporate mermaid diagrams into our jekyll page by using the predefined invocation block for mermaid. https://github.com/ioos/mbon-docs/commit/4898515222c199b4d2fad960fd8fd0618cbdb9ad

```mermaid

For some reason, this complex diagram doesn't jiive with the js for mermaid. But the diagram works just fine in the live editor https://mermaid.live and if I keep the previous stuff. No clue what's up with it.

MathewBiddle commented 1 month ago

For now, I reverted back to the previous way for embedding mermaid diagrams.

ocefpaf commented 1 month ago

The live editor probably uses a modern version of the JS lib. I'll check how/if we can update it in our jekyll theme too.

ocefpaf commented 1 month ago

Nope. Even using the same version as the live editor we get that syntax error. The {} can be confused with jinja and that we need the raw there to escape them. A diagram without curly braces would work without the escaping.

Screenshot from 2024-07-22 20-49-09

7yl4r commented 1 month ago

so this should work?:


{% raw %}
```mermaid
graph LR
A --> B(B)
```
{% endraw %}

GitHub rendered:

{% raw %}

graph LR
A --> B(B)

{% endraw %}

ocefpaf commented 1 month ago

so this should work?

You mean GH notifications, right? The only jekyll pages will require the raw to avoid conflicting with the jinja syntax.

MathewBiddle commented 1 day ago

Figured out the issue. Jekyll uses `{{}} as something special. Mermaid uses it to make a different shaped box. When Jekyll renders the html, it removes the {{}} and double quotes, thus breaking the Mermaid syntax:

image

When it should look like the markdown, when rendered in html:

https://github.com/ioos/mbon-docs/blob/bc5a55ac8dbff9133a903b0d9703957295658cd7/_docs/mbon-data-flow.md?plain=1#L39-L40

So, adjusting the shape to something different should fix this specific issue.

I'll update https://ioos.github.io/ioos-documentation-jekyll-skeleton/howto.html#adding-mermaid-diagrams-to-a-page with these details.

ocefpaf commented 1 day ago

Figured out the issue. Jekyll uses `{{}}

Yep. That is why we need the raw, so jekyll doesn't interpret it as a liquid tag. However, if changing the shape is an option, that is much easier to maintain then skipping syntax everywhere.

MathewBiddle commented 23 hours ago

I didn't do a PR here, but this fixed the issue: https://github.com/ioos/mbon-docs/commit/ab00ac10f502b0208d9b45e0dc9a094e49d9b374

https://ioos.github.io/mbon-docs/mbon-data-flow.html