How to create simple flowcharts

To create a codeblock we encapsulate the text within triple-backticks ``` like so:

```
code or output goes in here
```


To follow a certain syntax, we specify it after the opening triple-backticks.

An example for non-colored-coded plain text:

```text
plain text, output, or other non-colored-coded text
goes in here
```

An example for bash:

```bash
#!/bin/bash
while true; do echo “Hello World”; sleep 10; done
exit


To create a simple graph or flowchart, invoke the Mermaid plugin.

```mermaid
graph or flowchart created in here
```

IMPORTANT NOTE: Unlike blocks of code, the Mermaid plugin is frustratingly “quirky” if you use the preview panel on the right side of the screen. It is recommended to attempt to create a flowchart “blind”, with the preview panel temporarily disabled. This will give you better control of your text and cursor, and prevent an “auto” resize being applied, which will “crop out” the chart. (Otherwise, you will have to fight with the plugin as it tries to intelligently auto-complete and interfere with your typing.) :face_with_symbols_over_mouth:

If you wish to incorporate “colors”, keep in mind that the chart may not appear legible to other readers using a different forum “theme”.


The following are simple examples that you can use as templates

In a sense, you declare objects by first creating them, which allows you to invoke them as “variables” by using their “names”. Objects can connect to each other with “lines”. That is the gist of it.

The desired “shapes” are created by specifying characters (or combinations of characters) after the object’s name. Such characters include [ ], ( ), [( )], { }, and so on.

The desired type of graph, chart, or diagram is specified immediately after invoking the plugin, such as this example for a “top-down” flowchart:

```mermaid
flowchart TD

Or for a “left-right” flowchart:

```mermaid
flowcart LR

Or for a Gantt time chart:

```mermaid
gantt

NOTE: The Mermaid plugin is very advanced. It supports different shapes, colors, strokes, styles, and so on. However, for the sake of these examples, I will try to avoid fine-grain complexities.


A simple “top-down” flowchart:

```mermaid
flowchart TD

user1(Admin)
choice1{“Destroy\nServer?”}
result1[“Arrested for\ndestruction of\nproperty”]
result2[“Arrested for\nnot protecting\ncustomer data”]

user1 → choice1
choice1 -->|YES| result1
choice1 -->|NO| result2
```

flowchart TD

user1(Admin)
choice1{"Destroy\nServer?"}
result1["Arrested for\ndestruction of\nproperty"]
result2["Arrested for\nnot protecting\ncustomer data"]

user1 --> choice1
choice1 -->|YES| result1
choice1 -->|NO| result2

A simple “left-to-right” graph:

```mermaid
flowchart LR

nas1[(“Main\nNAS”)]
nas2[(“Backup\nNAS”)]
dsDocs(“Documents\nDataset”)
dsDocsBak(“Docs Dataset\n(backup)”)
dsDLs(“Downloads\nDataset”)

nas1 — dsDocs
nas1 — dsDLs
nas2 — dsDocsBak
dsDocs -…->|DAILY\nREPLICATION| dsDocsBak

style note fill:lightyellow,color:black
note>“My DLs are saved\non another USB”]
```

flowchart LR

nas1[("Main\nNAS")] 
nas2[("Backup\nNAS")]
dsDocs("Documents\nDataset")
dsDocsBak("Docs Dataset\n(backup)")
dsDLs("Downloads\nDataset")

nas1 --- dsDocs
nas1 --- dsDLs
nas2 --- dsDocsBak
dsDocs -..->|DAILY\nREPLICATION| dsDocsBak

style note fill:lightyellow,color:black
note>"My DLs are saved\non another USB"]

You can also use “colors”. Although, you should consider other readers who are using different forum themes. It might be wise to only change the “border” color or thickness.

```mermaid
flowchart LR

style result1 stroke:green,stroke-width:4px
style result2 stroke:red,stroke-width:4px

user1(Admin)
choice1{“Create\nBackups?”}
result1[“Happy\nlife”]
result2[“Eventually\nlose everything”]

user1 → choice1
choice1 -->|YES| result1
choice1 -->|NO| result2
```

flowchart LR

style result1 stroke:green,stroke-width:4px
style result2 stroke:red,stroke-width:4px

user1(Admin)
choice1{"Create\nBackups?"}
result1["Happy\nlife"]
result2["Eventually\nlose everything"]

user1 --> choice1
choice1 -->|YES| result1
choice1 -->|NO| result2

To learn more about Mermaid’s syntax, read the documentation on their website.

There is also a helpful cheat sheet.

6 Likes

Important note:

This is a tilde: ~
This is a grave accent: `

Backticks, as the ASCII grave accent is sometimes called, are evil, they’re like a worse apostrophe that was added to US layout keyboards to confuse people and pad out a key that only did one thing. They’re terrible in shell scripts and they’re terrible for formatting things.

Why does ASCII have a grave accent character without a letter to accent? Look, it was decades ago and certain things were in the air. Besides, EBCDIC is worse, so don’t complain too much.

If you have to type out that wretched character, go out and buy a US layout keyboard. If that feels extreme, just throw grave accents out into the vacuum without letters - shift+acute accent, shift+acute accent, shift+acute accent, space.

Better yet, just use the editor’s pre-formatted text button.

2 Likes

Are the grave accents in the room with us right now?

:smirk:

As a native speaker of a language that actually uses them, yes. Yes they are.

3 Likes

Painfully difficult… I think MS-Paint is more my speed…

2 Likes

But at least on FreeBSD, those ` are used to cause what is contained between a pair of them to be expanded, such as to insert the output of a command into another script.

Not sure when those were added and how it coincides with the command expansion effect.

Not sure if that’s FreeBSD per se, but rather a feature of the csh shell?

It is likely specific to a shell or a few shells.