{{ if .Page.Params.mermaid -}}
  <div class="mermaid{{ with .Get "class" }} {{ . }}{{ end }}">
    {{ $data := replaceRE "(^\\s+```)" "" .Inner -}}
    {{ replaceRE "(```\\s+$)" "" $data -}}
  </div>
{{ else -}}
  {{ errorf "Failed to process mermaid shortcode: %s. Set mermaid to true in page front matter." .Position }}
{{ end -}}
