@prefix sioc: <http://rdfs.org/sioc/ns#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix content: <http://purl.org/rss/1.0/modules/content/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<https://lhero.org/portfolio/lh-mermaid/>
  a sioc:Post ;
  dc:title "The Mermaid Diagram block" ;
  dcterms:identifier 151947 ;
  dc:modified "2026-10-21T01:03:28Z"^^xsd:dateTime ;
  dc:created "2026-10-20T21:40:34Z"^^xsd:dateTime ;
  sioc:link <https://lhero.org/portfolio/lh-mermaid/the-mermaid-diagram-block/> ;
  sioc:has_creator <https://lhero.org/author/1/#account> ;
  sioc:has_container <https://lhero.org/#posts> ;
  content:encoded """<ul class="lh_portfolio-meta"><li><strong>Part of:</strong> <a href="https://lhero.org/portfolio/lh-mermaid/">LH Mermaid</a></li></ul>
<p class="wp-block-paragraph">Add <strong>Mermaid Diagram</strong> from the inserter on any post type, type the diagram in <a href="https://mermaid.js.org/intro/syntax-reference.html">Mermaid syntax</a>, and use the toolbar&#8217;s <strong>Preview</strong> button to see it drawn. <strong>Source</strong> returns to the text. Wide and full alignment and an HTML anchor are supported.</p>



<h3 class="wp-block-heading">How it is stored</h3>



<p class="wp-block-paragraph">The block is static. The diagram source is saved as the plain text of a <code>pre</code> element and nowhere else, so it is versioned by revisions and anything that can write post content can write a diagram:</p>



<pre class="wp-block-code"><code>&lt;!-- wp:lh-mermaid/diagram --&gt;
&lt;pre class="wp-block-lh-mermaid-diagram mermaid"&gt;flowchart LR
  A[Draft] --&gt; B{Review}
  B --&gt;|Approved| C[Publish]&lt;/pre&gt;
&lt;!-- /wp:lh-mermaid/diagram --&gt;</code></pre>



<p class="wp-block-paragraph">Inside the <code>pre</code>, escape <code>&lt;</code> and <code>&amp;</code> as entities. <code>&gt;</code> may be written raw or as <code>&amp;gt;</code>; both draw the same.</p>



<h3 class="wp-block-heading">How it is drawn</h3>



<ul class="wp-block-list">
<li>Mermaid and a small stylesheet are loaded only on requests that render a diagram.</li>



<li>The library turns the source into an SVG in the browser. In feeds, email and anywhere without JavaScript, readers see the source text as an ordinary preformatted block.</li>



<li>The library is excluded from LH Defer Javascript&#8217;s lazy loading (through its <code>lh_defer_javascript_exclude_scripts</code> filter), because Mermaid draws on the page load event and a late-loaded library would draw nothing.</li>



<li>In LH Presentations decks, diagrams are drawn slide by slide as each slide is shown.</li>
</ul>



<h3 class="wp-block-heading">Hiding the block</h3>



<p class="wp-block-paragraph">There is no setting. To remove the block from the inserter somewhere, filter <code>lh_mermaid_block_enabled</code>, which receives <code>$enabled</code>, the post being edited and the editor context:</p>



<pre class="wp-block-code"><code>add_filter( 'lh_mermaid_block_enabled', function ( $enabled, $post ) {
    return ( $post &amp;&amp; 'page' === $post-&gt;post_type ) ? false : $enabled;
}, 10, 2 );</code></pre>
"""^^rdf:XMLLiteral ;
  sioc:content """Part of: LH Mermaid
Add Mermaid Diagram from the inserter on any post type, type the diagram in Mermaid syntax, and use the toolbar&#8217;s Preview button to see it drawn. Source returns to the text. Wide and full alignment and an HTML anchor are supported.



How it is stored



The block is static. The diagram source is saved as the plain text of a pre element and nowhere else, so it is versioned by revisions and anything that can write post content can write a diagram:



&lt;!-- wp:lh-mermaid/diagram --&gt;
&lt;pre class="wp-block-lh-mermaid-diagram mermaid"&gt;flowchart LR
  A[Draft] --&gt; B{Review}
  B --&gt;|Approved| C[Publish]&lt;/pre&gt;
&lt;!-- /wp:lh-mermaid/diagram --&gt;



Inside the pre, escape &lt; and &amp; as entities. &gt; may be written raw or as &amp;gt;; both draw the same.



How it is drawn




Mermaid and a small stylesheet are loaded only on requests that render a diagram.



The library turns the source into an SVG in the browser. In feeds, email and anywhere without JavaScript, readers see the source text as an ordinary preformatted block.



The library is excluded from LH Defer Javascript&#8217;s lazy loading (through its lh_defer_javascript_exclude_scripts filter), because Mermaid draws on the page load event and a late-loaded library would draw nothing.



In LH Presentations decks, diagrams are drawn slide by slide as each slide is shown.




Hiding the block



There is no setting. To remove the block from the inserter somewhere, filter lh_mermaid_block_enabled, which receives $enabled, the post being edited and the editor context:



add_filter( 'lh_mermaid_block_enabled', function ( $enabled, $post ) {
    return ( $post &amp;&amp; 'page' === $post-&gt;post_type ) ? false : $enabled;
}, 10, 2 );
""" ;
  sioc:topic <https://lhero.org/?taxonomy=author&term=cap-1> .

<https://lhero.org/author/1/#account> rdfs:seeAlso <https://lhero.org/author/1/?feed=lhrdf&format=turtle> .
<https://lhero.org/?taxonomy=author&term=cap-1> rdfs:seeAlso <https://lhero.org/?taxonomy=author&term=cap-1&feed=lhrdf&format=turtle> .
