mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-14 20:37:55 -05:00
d706529720
a393f4cf4 Add a Spellcheck GitHub Action and config 8b6b1c381 netlify: Bump to Hugo 0.93.3 84515c183 Delete deployment-with-nanobox.md dd45f9899 Fix typos in docs e69de81a9 Update build-options.md 7745b7891 netlify: Hubo 0.93.2 037d63364 Clarify GitHub Pages Branches 94660c34b add missing %s 325de15e2 fix link to latest release note since the release notes were moved to GitHub: https://gohugo.io/news/no-more-releasenotes-here/ dbff41d01 Update introduction.md 0ecd627f7 netlify: Hugo 0.93.1 a74e16582 Update diagrams.md 33e310956 Add Goat example to test styling fa0100a5b Update diagrams.md 64ac75367 Adjust diagram docs f1d600044 Update theme 95bedff1a netlify: Bump to Hugo 0.93.0 849a8437f Merge commit 'c1398b91a9f4c67876b31feb67516b252e654d3c' c0c60c43c docs: Regenerate docs helper 2c63fe518 cod: Regen CLI docs f33ba4e5a CodeblockContext method renames 979b47968 Move the Goat template to the correct place 2df37e9e8 Add Markdown diagrams and render hooks for code blocks bd8037d43 Allow images to be cropped without being resized 8b2af4b49 modules: Add modules.Workspace config for Go 1.18 46b99dea1 Add --printUnusedTemplates 1285302c9 commands: Rename --i18n-warnings to printI18nWarnings dea2242c6 commands: Rename --path-warnings, --print-men to --printPathWarnings, --printMemoryUsage db782ea46 deps: Update github.com/alecthomas/chroma v0.9.4 => v0.10.0 git-subtree-dir: docs git-subtree-split: a393f4cf43829011e96d109de2f039a9b05b2d16
277 lines
14 KiB
Markdown
277 lines
14 KiB
Markdown
---
|
||
title: Diagrams
|
||
date: 2022-02-20
|
||
categories: [content management]
|
||
keywords: [diagrams,drawing]
|
||
menu:
|
||
docs:
|
||
parent: "content-management"
|
||
weight: 22
|
||
weight: 22
|
||
toc: true
|
||
---
|
||
|
||
|
||
{{< new-in "0.93.0" >}}
|
||
|
||
|
||
## GoAT Diagrams (Ascii)
|
||
|
||
Hugo supports [GoAT](https://github.com/bep/goat) natively. 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
|
||
|
||
```
|
||
````
|
||
|
||
Will be rendered as:
|
||
|
||
```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
|
||
```
|
||
|
||
|
||
|
||
|
||
|
||
## Mermaid Diagrams
|
||
|
||
Hugo currently does not provide default templates for Mermaid diagrams. But you can easily add your own. One way to do it would be to create ` layouts/_default/_markup/render-codeblock-mermaid.html`:
|
||
|
||
|
||
```go-html-template
|
||
<div class="mermaid">
|
||
{{- .Inner | safeHTML }}
|
||
</div>
|
||
{{ .Page.Store.Set "hasMermaid" true }}
|
||
```
|
||
|
||
And then include this snippet at the bottom of the content template (below `.Content`):
|
||
|
||
```go-html-template
|
||
{{ if .Page.Store.Get "hasMermaid" }}
|
||
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
|
||
<script>
|
||
mermaid.initialize({ startOnLoad: true });
|
||
</script>
|
||
{{ end }}
|
||
```
|
||
|
||
With that you can use the `mermaid` language in Markdown code blocks:
|
||
|
||
```mermaid
|
||
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 <br/>prevail!
|
||
John-->>Alice: Great!
|
||
John->>Bob: How about you?
|
||
Bob-->>John: Jolly good!
|
||
```
|
||
|
||
|
||
|
||
## Goat Ascii Diagram Examples
|
||
|
||
### Graphics
|
||
|
||
```goat
|
||
.
|
||
0 3 P * Eye / ^ /
|
||
*-------* +y \ +) \ / Reflection
|
||
1 /| 2 /| ^ \ \ \ v
|
||
*-------* | | v0 \ v3 --------*--------
|
||
| |4 | |7 | *----\-----*
|
||
| *-----|-* +-----> +x / v X \ .-.<-------- o
|
||
|/ |/ / / o \ | / | Refraction / \
|
||
*-------* v / \ +-' / \
|
||
5 6 +z v1 *------------------* v2 | o-----o
|
||
v
|
||
|
||
```
|
||
|
||
### Complex
|
||
|
||
```goat
|
||
+-------------------+ ^ .---.
|
||
| A Box |__.--.__ __.--> | .-. | |
|
||
| | '--' v | * |<--- | |
|
||
+-------------------+ '-' | |
|
||
Round *---(-. |
|
||
.-----------------. .-------. .----------. .-------. | | |
|
||
| Mixed Rounded | | | / Diagonals \ | | | | | |
|
||
| & Square Corners | '--. .--' / \ |---+---| '-)-' .--------.
|
||
'--+------------+-' .--. | '-------+--------' | | | | / Search /
|
||
| | | | '---. | '-------' | '-+------'
|
||
|<---------->| | | | v Interior | ^
|
||
' <---' '----' .-----------. ---. .--- v |
|
||
.------------------. Diag line | .-------. +---. \ / . |
|
||
| if (a > b) +---. .--->| | | | | Curved line \ / / \ |
|
||
| obj->fcn() | \ / | '-------' |<--' + / \ |
|
||
'------------------' '--' '--+--------' .--. .--. | .-. +Done?+-'
|
||
.---+-----. | ^ |\ | | /| .--+ | | \ /
|
||
| | | Join \|/ | | Curved | \| |/ | | \ | \ /
|
||
| | +----> o --o-- '-' Vertical '--' '--' '-- '--' + .---.
|
||
<--+---+-----' | /|\ | | 3 |
|
||
v not:line 'quotes' .-' '---'
|
||
.-. .---+--------. / A || B *bold* | ^
|
||
| | | Not a dot | <---+---<-- A dash--is not a line v |
|
||
'-' '---------+--' / Nor/is this. ---
|
||
|
||
```
|
||
|
||
### Process
|
||
|
||
```goat
|
||
.
|
||
.---------. / \
|
||
| START | / \ .-+-------+-. ___________
|
||
'----+----' .-------. A / \ B | |COMPLEX| | / \ .-.
|
||
| | END |<-----+CHOICE +----->| | | +--->+ PREPARATION +--->| X |
|
||
v '-------' \ / | |PROCESS| | \___________/ '-'
|
||
.---------. \ / '-+---+---+-'
|
||
/ INPUT / \ /
|
||
'-----+---' '
|
||
| ^
|
||
v |
|
||
.-----------. .-----+-----. .-.
|
||
| PROCESS +---------------->| PROCESS |<------+ X |
|
||
'-----------' '-----------' '-'
|
||
```
|
||
|
||
### File tree
|
||
|
||
Created from https://arthursonzogni.com/Diagon/#Tree
|
||
|
||
```goat { width=300 color="orange" }
|
||
───Linux─┬─Android
|
||
├─Debian─┬─Ubuntu─┬─Lubuntu
|
||
│ │ ├─Kubuntu
|
||
│ │ ├─Xubuntu
|
||
│ │ └─Xubuntu
|
||
│ └─Mint
|
||
├─Centos
|
||
└─Fedora
|
||
```
|
||
|
||
|
||
### Sequence Diagram
|
||
|
||
https://arthursonzogni.com/Diagon/#Sequence
|
||
|
||
```goat { class="w-40" }
|
||
┌─────┐ ┌───┐
|
||
│Alice│ │Bob│
|
||
└──┬──┘ └─┬─┘
|
||
│ │
|
||
│ Hello Bob! │
|
||
│───────────>│
|
||
│ │
|
||
│Hello Alice!│
|
||
│<───────────│
|
||
┌──┴──┐ ┌─┴─┐
|
||
│Alice│ │Bob│
|
||
└─────┘ └───┘
|
||
|
||
```
|
||
|
||
|
||
### Flowchart
|
||
|
||
https://arthursonzogni.com/Diagon/#Flowchart
|
||
|
||
```goat
|
||
_________________
|
||
╱ ╲ ┌─────┐
|
||
╱ DO YOU UNDERSTAND ╲____________________________________________________│GOOD!│
|
||
╲ FLOW CHARTS? ╱yes └──┬──┘
|
||
╲_________________╱ │
|
||
│no │
|
||
_________▽_________ ______________________ │
|
||
╱ ╲ ╱ ╲ ┌────┐ │
|
||
╱ OKAY, YOU SEE THE ╲________________╱ ... AND YOU CAN SEE ╲___│GOOD│ │
|
||
╲ LINE LABELED 'YES'? ╱yes ╲ THE ONES LABELED 'NO'? ╱yes└──┬─┘ │
|
||
╲___________________╱ ╲______________________╱ │ │
|
||
│no │no │ │
|
||
________▽_________ _________▽__________ │ │
|
||
╱ ╲ ┌───────────┐ ╱ ╲ │ │
|
||
╱ BUT YOU SEE THE ╲___│WAIT, WHAT?│ ╱ BUT YOU JUST ╲___ │ │
|
||
╲ ONES LABELED 'NO'? ╱yes└───────────┘ ╲ FOLLOWED THEM TWICE? ╱yes│ │ │
|
||
╲__________________╱ ╲____________________╱ │ │ │
|
||
│no │no │ │ │
|
||
┌───▽───┐ │ │ │ │
|
||
│LISTEN.│ └───────┬───────┘ │ │
|
||
└───┬───┘ ┌──────▽─────┐ │ │
|
||
┌─────▽────┐ │(THAT WASN'T│ │ │
|
||
│I HATE YOU│ │A QUESTION) │ │ │
|
||
└──────────┘ └──────┬─────┘ │ │
|
||
┌────▽───┐ │ │
|
||
│SCREW IT│ │ │
|
||
└────┬───┘ │ │
|
||
└─────┬─────┘ │
|
||
│ │
|
||
└─────┬─────┘
|
||
┌───────▽──────┐
|
||
│LET'S GO DRING│
|
||
└───────┬──────┘
|
||
┌─────────▽─────────┐
|
||
│HEY, I SHOULD TRY │
|
||
│INSTALLING FREEBSD!│
|
||
└───────────────────┘
|
||
|
||
```
|
||
|
||
|
||
### Table
|
||
|
||
https://arthursonzogni.com/Diagon/#Table
|
||
|
||
```goat { class="w-80 dark-blue" }
|
||
┌────────────────────────────────────────────────┐
|
||
│ │
|
||
├────────────────────────────────────────────────┤
|
||
│SYNTAX = { PRODUCTION } . │
|
||
├────────────────────────────────────────────────┤
|
||
│PRODUCTION = IDENTIFIER "=" EXPRESSION "." . │
|
||
├────────────────────────────────────────────────┤
|
||
│EXPRESSION = TERM { "|" TERM } . │
|
||
├────────────────────────────────────────────────┤
|
||
│TERM = FACTOR { FACTOR } . │
|
||
├────────────────────────────────────────────────┤
|
||
│FACTOR = IDENTIFIER │
|
||
├────────────────────────────────────────────────┤
|
||
│ | LITERAL │
|
||
├────────────────────────────────────────────────┤
|
||
│ | "[" EXPRESSION "]" │
|
||
├────────────────────────────────────────────────┤
|
||
│ | "(" EXPRESSION ")" │
|
||
├────────────────────────────────────────────────┤
|
||
│ | "{" EXPRESSION "}" . │
|
||
├────────────────────────────────────────────────┤
|
||
│IDENTIFIER = letter { letter } . │
|
||
├────────────────────────────────────────────────┤
|
||
│LITERAL = """" character { character } """" .│
|
||
└────────────────────────────────────────────────┘
|
||
```
|
||
|
||
|
||
|