Back

GoAT diagrams (ASCII)

Hugo natively supports [GoAT] diagrams with an [embedded code block render hook]. This means that this code block:

```goat
      .               .                .               .--- 1          .-- 1     / 1
     / \              |                |           .---+            .-+         +
    /   \         .---+---.         .--+--.        |   '--- 2      |   '-- 2   / \ 2
   +     +        |       |        |       |    ---+            ---+          +
  / \   / \     .-+-.   .-+-.     .+.     .+.      |   .--- 3      |   .-- 3   \ / 3
 /   \ /   \    |   |   |   |    |   |   |   |     '---+            '-+         +
 1   2 3   4    1   2   3   4    1   2   3   4         '--- 4          '-- 4     \ 4

```
txt

Will be rendered as:

123412341234123412341234

Mermaid diagrams

Hugo does not provide a built-in template for Mermaid diagrams. Create your own using a code block render hook:

<pre class="mermaid">
  {{ .Inner | htmlEscape | safeHTML }}
</pre>
{{ .Page.Store.Set "hasMermaid" true }}
go-html-template

Then include this snippet at the bottom of your base template, before the closing body tag:

{{ if .Store.Get "hasMermaid" }}
  <script type="module">
    import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
    mermaid.initialize({ startOnLoad: true });
  </script>
{{ end }}
go-html-template

With that you can use the mermaid language in Markdown code blocks:

sequenceDiagram
    participant Alice
    participant Bob
    Alice->>John: Hello John, how are you?
    loop Healthcheck
        John->>John: Fight against hypochondria
    end
    Note right of John: Rational thoughts 
prevail! John-->>Alice: Great! John->>Bob: How about you? Bob-->>John: Jolly good!
sequenceDiagram
    participant Alice
    participant Bob
    Alice->>John: Hello John, how are you?
    loop Healthcheck
        John->>John: Fight against hypochondria
    end
    Note right of John: Rational thoughts 
prevail! John-->>Alice: Great! John->>Bob: How about you? Bob-->>John: Jolly good!

Goat ASCII diagram examples

Graphics

15042637+z+y+xv1vP0Xv3Eyve2RefractionReflection

Complex

&AMSioiqfbBxujoea(-xdra>efR>coCnuob(nr))dneeJdrosinNoRDtoiuaangddloitneDiagonalsCVuerrvteidcalnotANC:ouldrriAa/Ivnsineehstd-e-trlBihiision'sreqn.u*oobttoelasd'*lineDonSee?arc3h

Process

PSIRTNOAPCRUETTSSENDACPHROOICCEESSBCPORMOXPCLEESXSPREPARATIONX

File tree

Created from https://arthursonzogni.com/Diagon/#Tree

LinuxADCFneeedbndritooaorinsadUMbiunnttuLKXXuuuubbbbuuuunnnnttttuuuu

Sequence diagram

https://arthursonzogni.com/Diagon/#Sequence

AAlliicH<ceHeeellllooABloibc!eB>!Boobb

Flowchart

https://arthursonzogni.com/Diagon/#Flowchart

OL_DF_KI_BO_OL_AN_UN_O_YE_TE_YW_,_S_IO_L_Y_UC_YA_OL_LHH_OB_UA_IAUA__UE__B_STNR_L_SE_TEDT_n_SE_n_EL_nEES_o_ED_o_EE_oNYR?__E__D_.OS__'__T_UT__TY__H'_A__HE__EN_N__ES__O_D__'__'__?__?__y_e_y_y_s_e_e__s_s____W__A__I__T__,____W__H__A__T__?_____T__H_BF__E_UO___TL__AO_L__NN_YO__DE_OW__S_UE__Y_D__OL__J__UA_UT__B_n_SH_n_CE_o_TE_o(A_AL__M_T_NE___HQS_D__T_AUC_S__W_TER_E'__I_SE_EN__C_WTW_O__E_AI_'__?_SOI_?_NNTHI_')EN__yTLYS__y_eE,T__e_sTA__s'IL_SL_GSI_OGHN_OOOG_DU_DLFRDRGIEONTEOGRBDYS!D!

Table

https://arthursonzogni.com/Diagon/#Table

SPETFILYRXEADINOPRCETTDRMTNEAUEOTRXCSRIATSFLIIIOOENNR||||=======L"""{ITFII[({l"DEADT"""e"PERCEEt"RNMTNREEEt"OTOTAXXXeDI{RILPPPrcUFFRRRhCI"{IEEE{aTE|ESSSrIR"FRSSSlaOAIIIecN"TCOOOtt=ETNNNte}"ROerMR"""r.E])}{X}}"""}PcR....hEaSrSaIcOtNer".}"".""".

[embedded code block render hook]: eturl render-codeblock-goat
[GoAT]: https://github.com/bep/goat

Diagrams
https://kkbt0.github.io/Somnia/posts/diagrams/
Author 恐咖兵糖
Published at
Copyright CC BY-NC-SA 4.0