1
1
# GoAT: Go ASCII Tool
2
2
3
- This is a Go implementation of [ markdeep.mini.js] 's ASCII diagram
4
- generation.
3
+ ## What ** GoAT** Can Do For You
5
4
6
- ## Update (2022-02-07)
5
+ - From a chunky ASCII-art source drawing, render polished, graphically-rich [ SVG] ( #complicated ) ,
6
+ with the [ goat] ( ./cmd/goat ) CLI command.
7
7
8
- I hacked together GoAT a number of years ago while trying to embed some
9
- diagrams in a Hugo project I was playing with. Through an odd twist of fate
10
- GoAT eventually made its way into the upstream Hugo project, and if you're
11
- using [ v0.93.0] you can embed these diagrams natively. Neat!
8
+ - Tie together all three of:
9
+ 1 . Your code's major data structures or abstract data/control flows.
10
+ 2 . Related ASCII-art diagrams embedded in comments, adjacent to the source code.
11
+ 3 . Polished line diagrams in your user-facing high-level documentation, with inline links
12
+ to SVG produced by [ goat] ( ./cmd/goat ) .
13
+ For Markdown or similar formats, links may be expanded either at build-time or run-time,
14
+ as needed by your doc tool suite.
12
15
13
- My original implementation was certainly buggy and not on par with markdeep.
14
- I'm grateful for the folks who've helped smooth out the rough edges, and I've
15
- updated this project to reflect the good changes made in the Hugo fork,
16
- including a long-overdue ` go.mod ` .
16
+ Your ASCII-art source persists as the single-point-of-truth, revision-controlled along with
17
+ the code that embeds it.
18
+ This README contains an [ example] ( #library-data-flow ) .
17
19
18
- There's a lot I would like to do with this project that I will never get to, so
19
- instead I recommend you look at these forks:
20
+ ## You Will Also Need
20
21
21
- * [ @bep ] is the fork currently used by Hugo, which I expect to be more active
22
- over time.
23
- * [ @dmacvicar ] has improved SVG/PNG/PDF rendering.
24
- * [ @sw46 ] has implemented a really wonderful hand-drawn style worth checking
25
- out.
22
+ #### Graphical- or Rectangle-oriented text editing capability
23
+ Both ** vim** and ** emacs** offer useful support.
24
+ In Emacs, see the built-in rectangle-editing commands, and ``` picture-mode ``` .
26
25
27
- ## Usage
26
+ #### A fixed-pitch font with 2:1 height: width ratio as presented by your editor and terminal emulator
27
+ Most fixed-pitch or "monospace" Unicode fonts maintain a 2:1 aspect ratio for
28
+ characters in the ASCII range,
29
+ and all GoAT drawing characters are ASCII.
30
+ However, certain Unicode graphical characters e.g. MIDDLE DOT may be useful, and
31
+ conform to the width of the ASCII range.
28
32
29
- ``` bash
30
- $ go get github.com/blampe/goat
31
- $ cat my-cool-diagram.txt | goat > my-cool-diagram.svg
32
- ```
33
-
34
- By default, the program reads from stdin, unless ` -i infile ` is given.
35
-
36
- By default, the program writes to stdout, unless ` -o outfile ` is given or a
37
- binary format with ` -f ` is selected.
38
-
39
- By default, it writes in [ SVG] format, unless another format is specified with
40
- ` -f ` .
33
+ CJK characters on the other hand are typically wider than 2:1.
34
+ Non-standard width characters are not in general composable on the left-right axis within a plain-text
35
+ drawing, because the remainder of the line of text to their right is pushed out of alignment
36
+ with rows above and below.
41
37
42
- ## TODO
43
-
44
- - Dashed lines signaled by ` : ` or ` = ` .
45
- - Bold lines signaled by ???.
38
+ ## Installation
39
+ ```
40
+ $ go install github.com/dmullis/goat/cmd/goat@latest
41
+ ```
46
42
47
43
## Examples
48
44
49
- Here are some SVGs and the UTF-8 input they were generated from:
45
+ Here are some snippets of
46
+ GoAT-formatted UTF-8
47
+ and the SVG each can generate.
48
+ The SVG you see below was linked to by
49
+ inline Markdown image references
50
+ ([ howto] ( https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#images ) ,
51
+ [ spec] ( https://github.github.com/gfm/#images ) ) from
52
+ GoAT's [ README.md] ( README.md ) , then finally rendered to HTML ``` <img> ``` elements by Github's Markdown processor
50
53
51
- ### Trees
52
-
53
- ![ Trees Example] ( https://cdn.rawgit.com/blampe/goat/main/examples/trees.svg )
54
54
55
+ ### Trees
55
56
```
57
+
56
58
. . . .--- 1 .-- 1 / 1
57
59
/ \ | | .---+ .-+ +
58
60
/ \ .---+---. .--+--. | '--- 2 | '-- 2 / \ 2
59
61
+ + | | | | ---+ ---+ +
60
62
/ \ / \ .-+-. .-+-. .+. .+. | .--- 3 | .-- 3 \ / 3
61
63
/ \ / \ | | | | | | | | '---+ '-+ +
62
64
1 2 3 4 1 2 3 4 1 2 3 4 '--- 4 '-- 4 \ 4
63
- ```
64
65
65
- ### Overlaps
66
66
67
- ![ Overlaps Example] ( https://cdn.rawgit.com/blampe/goat/main/examples/overlaps.svg )
67
+ ```
68
+ ![ ] ( ./examples/trees.svg )
68
69
70
+ ### Overlaps
69
71
```
72
+
70
73
.-. .-. .-. .-. .-. .-.
71
74
| | | | | | | | | | | |
72
75
.---------. .--+---+--. .--+---+--. .--| |--. .--+ +--. .------|--.
73
76
| | | | | | | | | | | | | | | | | |
74
77
'---------' '--+---+--' '--+---+--' '--| |--' '--+ +--' '--|------'
75
78
| | | | | | | | | | | |
76
79
'-' '-' '-' '-' '-' '-'
80
+
77
81
```
82
+ ![ ] ( ./examples/overlaps.svg )
78
83
79
84
### Line Decorations
80
-
81
- ![ Line Decorations Example] ( https://cdn.rawgit.com/blampe/goat/main/examples/line-decorations.svg )
82
-
83
85
```
84
86
________ o * * .--------------.
85
87
*---+--. | | o o | ^ \ / | .----------. |
@@ -88,12 +90,11 @@ Here are some SVGs and the UTF-8 input they were generated from:
88
90
<--' ^ ^ | | | | | ^ \ | '--------' | |
89
91
\/ *-----' o |<----->| '-----' |__| v '------------' |
90
92
/\ *---------------'
93
+
91
94
```
95
+ ![ ] ( ./examples/line-decorations.svg )
92
96
93
97
### Line Ends
94
-
95
- ![ Line Ends Example] ( https://cdn.rawgit.com/blampe/goat/main/examples/line-ends.svg )
96
-
97
98
```
98
99
o--o *--o / / * o o o o o * * * * o o o o * * * * o o o o * * * *
99
100
o--* *--* v v ^ ^ | | | | | | | | \ \ \ \ \ \ \ \ / / / / / / / /
@@ -105,26 +106,28 @@ Here are some SVGs and the UTF-8 input they were generated from:
105
106
* o | | * o \ \
106
107
107
108
<--o <--* <--> <--- ---o ---* ---> ---- *<-- o<-- -->o -->*
108
- ```
109
109
110
- ### Dot Grids
111
110
112
- ![ Dot Grids Example] ( https://cdn.rawgit.com/blampe/goat/main/examples/dot-grids.svg )
111
+ ```
112
+ ![ ] ( ./examples/line-ends.svg )
113
113
114
+ ### Dot Grids
114
115
```
116
+
115
117
o o o o o * * * * * * * o o * o o o * * * o o o · * · · · · · ·
116
118
o o o o o * * * * * o o o o * o o o o * * * * * o * * · * * · · · · · ·
117
119
o o o o o * * * * * o * o o o o o o o o * * * * * o o o o o · o · · o · · * * ·
118
120
o o o o o * * * * * o * o o o o o o o * * * * o * o o · · · · o · · * ·
119
121
o o o o o * * * * * * * * * o o o o * * * o * o · · · · · · · *
122
+
123
+
120
124
```
121
125
Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character, encoded with UTF-8.
126
+ ![ ] ( ./examples/dot-grids.svg )
122
127
123
128
### Large Nodes
124
-
125
- ![ Large Node Example] ( https://cdn.rawgit.com/blampe/goat/main/examples/large-nodes.svg )
126
-
127
129
```
130
+
128
131
.---. .-. .-. .-. .-.
129
132
| A +----->| 1 +<---->| 2 |<----+ 4 +------------------. | 8 |
130
133
'---' '-' '+' '-' | '-'
@@ -133,12 +136,12 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character,
133
136
.-. .-+-. .-. .-+-. .-. .+. .---.
134
137
| 3 +---->| B |<----->| 5 +---->| C +---->| 6 +---->| 7 |<---->| D |
135
138
'-' '---' '-' '---' '-' '-' '---'
139
+
136
140
```
141
+ ![ ] ( ./examples/large-nodes.svg )
137
142
138
143
### Small Grids
139
-
140
- ![ Small Grids Example] ( https://cdn.rawgit.com/blampe/goat/main/examples/small-grids.svg )
141
-
144
+ ![ ] ( ./examples/small-grids.svg )
142
145
```
143
146
___ ___ .---+---+---+---+---. .---+---+---+---. .---. .---.
144
147
___/ \___/ \ | | | | | | / \ / \ / \ / \ / | +---+ |
@@ -147,12 +150,11 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character,
147
150
/ a \___/ \___/ +---+---+---+---+---+ +---+---+---+---+ +---+ b +---+
148
151
\___/ \___/ \ | | a | | | | / \ / \ / \ / \ / | a +---+ |
149
152
\___/ \___/ '---+---+---+---+---' '---+---+---+---' '---' '---'
150
- ```
151
153
152
- ### Big Grids
153
154
154
- ![ Big Grids Example ] ( https://cdn.rawgit.com/blampe/goat/main/examples/big-grids.svg )
155
+ ```
155
156
157
+ ### Big Grids
156
158
```
157
159
.----. .----.
158
160
/ \ / \ .-----+-----+-----.
@@ -165,12 +167,12 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character,
165
167
'----+ +----+ + | | | | +-----+-----+-----+-----+
166
168
\ / \ / | A | | | / / / / /
167
169
'----' '----' '-----+-----+-----' '-----+-----+-----+-----+
168
- ```
169
170
170
- ### Complicated
171
171
172
- ![ Complicated Example] ( https://cdn.rawgit.com/blampe/goat/main/examples/complicated.svg )
172
+ ```
173
+ ![ ] ( ./examples/big-grids.svg )
173
174
175
+ ### Complicated
174
176
```
175
177
+-------------------+ ^ .---.
176
178
| A Box |__.--.__ __.--> | .-. | |
@@ -196,9 +198,31 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character,
196
198
.-. .---+--------. / A || B *bold* | ^
197
199
| | | Not a dot | <---+---<-- A dash--is not a line v |
198
200
'-' '---------+--' / Nor/is this. ---
201
+
199
202
```
203
+ ![ ] ( ./examples/complicated.svg )
204
+
205
+ ### More examples are [ here] ( examples )
206
+
207
+ ## The GoAT Library
208
+
209
+ The core engine of ``` goat ``` is accessible as a Go library package, for inclusion in specialized
210
+ code of your own.
211
+ The code implements a subset, and some extensions, of the ASCII diagram generation function of the browser-side Javascript in [ Markdeep] ( http://casual-effects.com/markdeep/ ) .
212
+
213
+ ### library Data Flow
214
+ ![ ] ( ./goat.svg )
215
+
216
+ The diagram above was derived by [ ./make.sh] ( ./make.sh ) from ASCII-art in the Go
217
+ source file [ ./goat.go] ( ./goat.go ) .
218
+
219
+ #### Project Tenets
200
220
201
- More examples are available [ here] ( examples ) .
221
+ 1 . Utility and ease of integration into existing projects are paramount.
222
+ 2 . Compatibility with MarkDeep desired, but not required.
223
+ 3 . TXT and SVG intelligibility are co-equal in priority.
224
+ 4 . Composability of TXT not to be sacrificed -- only width-8 characters allowed.
225
+ 5 . Per-platform support limited to a single widely-available fixed-pitch TXT font.
202
226
203
227
[ @bep ] : https://github.com/bep/goat/
204
228
[ @dmacvicar ] : https://github.com/dmacvicar/goat
0 commit comments