abc: box diagrams

abc, for ascii box characters, draws box and arrow diagrams. The diagram is written with ordinary keyboard characters, and the translator draws it with Unicode box characters. It is Rick Workman's design, from a MyWord package of his; its grammar is abc.peg.

This document is also the abc def-sheet. Only its definition lines count, so a document that names it, with sheets: abc.mym, gets just the lines that matter, ```abc => abc and ```array => array, and the functions in abc_html.py beside it. The manual comes along with the notation, and stays out of the way. The second line is for another of Rick's packages, his array, at the end.

A diagram is usually written in a fence labelled ```abc, which reads as code anywhere Markdown is shown. In a demo below it is written the other way, as a ```abc line and | lines, because a Markdown fence cannot go inside a demo. Each demo shows the source, then the drawing.

The drawing depends on the monospaced font: the box characters should touch, and in some fonts they do not quite.

The pieces

```abc
| Corners:  .-   -.-   -.    |-   -|-   -|    '-   -'-   -'
|
| Lines:    |  and  -----
|
| Arrows:   <-   ->   <->
Corners:  ┌─   ─┬─   ─┐    ├─   ─┼─   ─┤    └─   ─┴─   ─┘

Lines:    │  and  ─────

Arrows:   ◀─   ─▶   ◀─▶

A corner is a dot or an apostrophe with a line beside it: a dot for a top corner, an apostrophe for a bottom one. A bar with a line beside it is a tee, and so is a dot or an apostrophe with a line on both sides.

Boxes

```abc
| .-------.
| | A Box |
| '-------'
┌───────┐
│ A Box │
└───────┘
```abc
| .----.----.
| | NW | NE |
| |----|----|
| | SW | SE |
| '----'----'
┌────┬────┐
│ NW │ NE │
├────┼────┤
│ SW │ SE │
└────┴────┘
```abc
| .-. .-.-. .-.-.
| '-' |-|-| |1|2|
|     '-'-' |-|-|
|           |3|4|
|           '-'-'
┌─┐ ┌─┬─┐ ┌─┬─┐
└─┘ ├─┼─┤ │1│2│
    └─┴─┘ ├─┼─┤
          │3│4│
          └─┴─┘

Arrows

A ^ is an arrowhead only when a | is directly below it, and a v only when a | is directly above it. Anywhere else they are just letters, so text in a diagram is safe.

```abc
|   ^          |       ^
|   |          |       |
|              v       v
|  up        down    both ways
|
| a v b, and 2 ^ 8: left as they are
  ▲          │       ▲
  │          │       │
             ▼       ▼
 up        down    both ways

a v b, and 2 ^ 8: left as they are
```abc
| .------.        .-------.
| | text |  --->  | parse |
| '------'        '-------'
┌──────┐        ┌───────┐
│ text │  ───▶  │ parse │
└──────┘        └───────┘

A bar with a line touching its right is a tee, so an arrow leaving a box joins it. With a space after the bar, the arrow stands free:

```abc
| .---.       .---.
| | a |--->   | b | --->
| '---'       '---'
┌───┐       ┌───┐
│ a ├───▶   │ b │ ───▶
└───┘       └───┘

Forks and joins

```abc
|     |       |   |      --.        .--
|   .-'-.     '-.-'        |--    --|
|   |   |       |        --'        '--
    │       │   │      ──┐        ┌──
  ┌─┴─┐     └─┬─┘        ├──    ──┤
  │   │       │        ──┘        └──

A larger diagram

```abc
|             .-----------.
|             |  mym text |
|             '-----------'
|                   |
|                   v
| .--------.  .-----------.  .------------.
| | inline |<-|   block   |->| definitions|
| | .peg   |  |   .peg    |  |  std.mym   |
| '--------'  '-----------'  '------------'
|                   |
|                   v
|             .-----------.
|             |   HTML    |
|             '-----------'
            ┌───────────┐
            │  mym text │
            └───────────┘
                  │
                  ▼
┌────────┐  ┌───────────┐  ┌────────────┐
│ inline │◀─┤   block   ├─▶│ definitions│
│ .peg   │  │   .peg    │  │  std.mym   │
└────────┘  └───────────┘  └────────────┘
                  │
                  ▼
            ┌───────────┐
            │   HTML    │
            └───────────┘

In a fence

Outside a demo, a diagram is written in a Markdown fence, with no | lines:

┌───────┐     ┌───────┐
│ mym   │ ──▶ │ HTML  │
└───────┘     └───────┘

Rick Workman's array

Another of Rick's MyWord packages, a table with no bars at all: a row is a line, and wide space, two spaces or a tab, parts the cells, so one space can go inside a cell. Like a diagram, it is a fence, ```array.

```array
| tea         3.50   hot
| lemon cake  4      *fresh*
tea3.50hot
lemon cake4fresh