+ '\n': ASCII/Unicode U+000A (category Cc: Other, control)</code></pre><h3 id="Saving-to-a-file"><a class="docs-heading-anchor" href="#Saving-to-a-file">Saving to a file</a><a id="Saving-to-a-file-1"></a><a class="docs-heading-anchor-permalink" href="#Saving-to-a-file" title="Permalink"></a></h3><p>Once a diagram has been rendered, it's straightforward to write it to a file using <code>write</code>.</p><pre><code class="language-julia hljs">write("mermaid_diagram.png", mermaid_diagram_as_png)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">9761</code></pre><p>Note the difference in file size when rendering to SVG.</p><pre><code class="language-julia hljs">write("mermaid_diagram.svg", render(mermaid_diagram, "svg"))</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">10254</code></pre><h3 id="Overriding-Base.show-behavior"><a class="docs-heading-anchor" href="#Overriding-Base.show-behavior">Overriding <code>Base.show</code> behavior</a><a id="Overriding-Base.show-behavior-1"></a><a class="docs-heading-anchor-permalink" href="#Overriding-Base.show-behavior" title="Permalink"></a></h3><p>In some cases the output format that is used may affect how the final diagram renders. Although it is always possible to explicitly fall back to calling <code>render</code> in these cases, this may be cumbersome when writing documentation, etc. and having to explicitly do that for every diagram of a specific type. As an alternative, it is possible to instruct <code>Kroki</code> to ignore certain output formats when rendering a specific diagram type using <code>Base.show</code>.</p><p>For instance, by default (in most cases) a Mermaid diagram will be rendered as an SVG. Due to the way these diagrams are rendered by Kroki this may result in text getting cut off, see <a href="https://github.com/yuzutech/kroki/issues/1345">yuzutech/kroki#1345</a> for details.</p><pre><code class="language-julia hljs">mermaid_diagram</code></pre><img src="55219bd2.svg" alt="Example block output"/><div class="admonition is-success"><header class="admonition-header">Inspecting the output format of an image</header><div class="admonition-body"><p>The most straightforward way of inspecting the output format is to open the image in a new tab in your browser and checking its extension, e.g. by right clicking on it and selecting <em>Open image in new tab</em> in Chrome or a similar browser. Alternatively the type of the rendered image can be seen by inspecting the source of this page.</p></div></div><p>Using <a href="../api/#Kroki.overrideShowable"><code>Kroki.overrideShowable</code></a>, <code>Kroki</code> can be instructed to not render to SVG and pick the next most suitable output format with a fallback of rendering the diagram to text if none are available.</p><pre><code class="language-julia hljs">Kroki.overrideShowable(MIME"image/svg+xml"(), :mermaid, false)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">false</code></pre><p>For Mermaid diagrams in the context of <code>Documenter</code> this means rendering the diagram as a PNG. When rendering to PNG the previously mentioned font issues do not arise.</p><pre><code class="language-julia hljs">mermaid_diagram</code></pre><img src="166322b9.png" alt="Example block output"/><h2 id="Controlling-text-rendering"><a class="docs-heading-anchor" href="#Controlling-text-rendering">Controlling text rendering</a><a id="Controlling-text-rendering-1"></a><a class="docs-heading-anchor-permalink" href="#Controlling-text-rendering" title="Permalink"></a></h2><p>Some diagrams support rendering to text, e.g. PlantUML and Structurizr. This can be based on ASCII or Unicode character sets. Which character set is used, is controlled using the <a href="../api/#Kroki.TEXT_PLAIN_SHOW_MIME_TYPE"><code>Kroki.TEXT_PLAIN_SHOW_MIME_TYPE</code></a> variable.</p><p>Setting a <code>text/plain</code> MIME type results in the use of the limited ASCII character set.</p><pre><code class="language-julia hljs">plantuml_diagram = plantuml"""
0 commit comments