1
1
# GoAT: Go ASCII Tool
2
- <!--
3
- NOTE to maintainers
4
- ---
5
- SVG examples/ regeneration.
6
- go test -run . -v -write
7
2
8
- Github home page README.md, specific to $USER:
9
- sed "s,{{\.Root}},https://cdn.rawgit.com/${USER}/goat/main," README.md.tmpl >README.md
3
+ ## What ** GoAT** Can Do For You
10
4
11
- Local preview of home page:
12
- sed "s,https://cdn.rawgit.com/blampe/goat/main,.," README.md.tmpl >README.md
13
- # See https://github.github.com/gfm/#introduction
14
- (echo '<!DOCTYPE html>'; marked -gfm README.md) >README.html
5
+ - From a chunky ASCII-art source drawing, render polished, graphically-rich [ SVG] ( #complicated ) ,
6
+ with the [ goat] ( ./cmd/goat ) CLI command.
15
7
16
- The @media query from SVG may be verified in Firefox by switching between Themes
17
- "Light" and "Dark" in Firefox's "Add-ons Manager".
18
- -->
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.
19
15
20
- This is a Go implementation of [ markdeep.mini.js] 's ASCII diagram
21
- generation.
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 ) .
22
19
23
- ## Update (2022-02-07)
20
+ ## You Will Also Need
24
21
25
- I hacked together GoAT a number of years ago while trying to embed some
26
- diagrams in a Hugo project I was playing with. Through an odd twist of fate
27
- GoAT eventually made its way into the upstream Hugo project, and if you're
28
- using [ v0.93.0] you can embed these diagrams natively. Neat!
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 ``` .
29
25
30
- My original implementation was certainly buggy and not on par with markdeep.
31
- I'm grateful for the folks who've helped smooth out the rough edges, and I've
32
- updated this project to reflect the good changes made in the Hugo fork,
33
- including a long-overdue ` go.mod ` .
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.
34
32
35
- There's a lot I would like to do with this project that I will never get to, so
36
- instead I recommend you look at these forks:
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.
37
37
38
- * [ @bep ] is the fork currently used by Hugo, which I expect to be more active
39
- over time.
40
- * [ @dmacvicar ] has improved SVG/PNG/PDF rendering.
41
- * [ @sw46 ] has implemented a really wonderful hand-drawn style worth checking
42
- out.
43
-
44
- ## Usage
45
-
46
- ``` bash
47
- $ go get github.com/blampe/goat
48
- $ cat my-cool-diagram.txt | goat > my-cool-diagram.svg
38
+ ## Installation
39
+ ```
40
+ $ go install github.com/blampe/goat/cmd/goat@latest
49
41
```
50
-
51
- By default, the program reads from stdin, unless ` -i infile ` is given.
52
-
53
- By default, the program writes to stdout, unless ` -o outfile ` is given or a
54
- binary format with ` -f ` is selected.
55
-
56
- By default, it writes in [ SVG] format, unless another format is specified with
57
- ` -f ` .
58
-
59
- ## TODO
60
-
61
- - Dashed lines signaled by ` : ` or ` = ` .
62
- - Bold lines signaled by ???.
63
42
64
43
## Examples
65
44
66
- Here are some SVGs and the UTF-8 input they were generated from:
67
-
68
- ### Trees
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
69
53
70
- ![ Trees Example] ( https://cdn.rawgit.com/blampe/goat/main/examples/trees.svg )
71
54
55
+ ### Trees
72
56
```
57
+
73
58
. . . .--- 1 .-- 1 / 1
74
59
/ \ | | .---+ .-+ +
75
60
/ \ .---+---. .--+--. | '--- 2 | '-- 2 / \ 2
76
61
+ + | | | | ---+ ---+ +
77
62
/ \ / \ .-+-. .-+-. .+. .+. | .--- 3 | .-- 3 \ / 3
78
63
/ \ / \ | | | | | | | | '---+ '-+ +
79
64
1 2 3 4 1 2 3 4 1 2 3 4 '--- 4 '-- 4 \ 4
80
- ```
81
65
82
- ### Overlaps
83
66
84
- ![ Overlaps Example] ( https://cdn.rawgit.com/blampe/goat/main/examples/overlaps.svg )
67
+ ```
68
+ ![ ] ( ./examples/trees.svg )
85
69
70
+ ### Overlaps
86
71
```
72
+
87
73
.-. .-. .-. .-. .-. .-.
88
74
| | | | | | | | | | | |
89
75
.---------. .--+---+--. .--+---+--. .--| |--. .--+ +--. .------|--.
90
76
| | | | | | | | | | | | | | | | | |
91
77
'---------' '--+---+--' '--+---+--' '--| |--' '--+ +--' '--|------'
92
78
| | | | | | | | | | | |
93
79
'-' '-' '-' '-' '-' '-'
80
+
94
81
```
82
+ ![ ] ( ./examples/overlaps.svg )
95
83
96
84
### Line Decorations
97
-
98
- ![ Line Decorations Example] ( https://cdn.rawgit.com/blampe/goat/main/examples/line-decorations.svg )
99
-
100
85
```
101
86
________ o * * .--------------.
102
87
*---+--. | | o o | ^ \ / | .----------. |
@@ -105,12 +90,11 @@ Here are some SVGs and the UTF-8 input they were generated from:
105
90
<--' ^ ^ | | | | | ^ \ | '--------' | |
106
91
\/ *-----' o |<----->| '-----' |__| v '------------' |
107
92
/\ *---------------'
93
+
108
94
```
95
+ ![ ] ( ./examples/line-decorations.svg )
109
96
110
97
### Line Ends
111
-
112
- ![ Line Ends Example] ( https://cdn.rawgit.com/blampe/goat/main/examples/line-ends.svg )
113
-
114
98
```
115
99
o--o *--o / / * o o o o o * * * * o o o o * * * * o o o o * * * *
116
100
o--* *--* v v ^ ^ | | | | | | | | \ \ \ \ \ \ \ \ / / / / / / / /
@@ -122,26 +106,28 @@ Here are some SVGs and the UTF-8 input they were generated from:
122
106
* o | | * o \ \
123
107
124
108
<--o <--* <--> <--- ---o ---* ---> ---- *<-- o<-- -->o -->*
125
- ```
126
109
127
- ### Dot Grids
128
110
129
- ![ Dot Grids Example] ( https://cdn.rawgit.com/blampe/goat/main/examples/dot-grids.svg )
111
+ ```
112
+ ![ ] ( ./examples/line-ends.svg )
130
113
114
+ ### Dot Grids
131
115
```
116
+
132
117
o o o o o * * * * * * * o o * o o o * * * o o o · * · · · · · ·
133
118
o o o o o * * * * * o o o o * o o o o * * * * * o * * · * * · · · · · ·
134
119
o o o o o * * * * * o * o o o o o o o o * * * * * o o o o o · o · · o · · * * ·
135
120
o o o o o * * * * * o * o o o o o o o * * * * o * o o · · · · o · · * ·
136
121
o o o o o * * * * * * * * * o o o o * * * o * o · · · · · · · *
122
+
123
+
137
124
```
138
125
Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character, encoded with UTF-8.
126
+ ![ ] ( ./examples/dot-grids.svg )
139
127
140
128
### Large Nodes
141
-
142
- ![ Large Node Example] ( https://cdn.rawgit.com/blampe/goat/main/examples/large-nodes.svg )
143
-
144
129
```
130
+
145
131
.---. .-. .-. .-. .-.
146
132
| A +----->| 1 +<---->| 2 |<----+ 4 +------------------. | 8 |
147
133
'---' '-' '+' '-' | '-'
@@ -150,12 +136,12 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character,
150
136
.-. .-+-. .-. .-+-. .-. .+. .---.
151
137
| 3 +---->| B |<----->| 5 +---->| C +---->| 6 +---->| 7 |<---->| D |
152
138
'-' '---' '-' '---' '-' '-' '---'
139
+
153
140
```
141
+ ![ ] ( ./examples/large-nodes.svg )
154
142
155
143
### Small Grids
156
-
157
- ![ Small Grids Example] ( https://cdn.rawgit.com/blampe/goat/main/examples/small-grids.svg )
158
-
144
+ ![ ] ( ./examples/small-grids.svg )
159
145
```
160
146
___ ___ .---+---+---+---+---. .---+---+---+---. .---. .---.
161
147
___/ \___/ \ | | | | | | / \ / \ / \ / \ / | +---+ |
@@ -164,12 +150,11 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character,
164
150
/ a \___/ \___/ +---+---+---+---+---+ +---+---+---+---+ +---+ b +---+
165
151
\___/ \___/ \ | | a | | | | / \ / \ / \ / \ / | a +---+ |
166
152
\___/ \___/ '---+---+---+---+---' '---+---+---+---' '---' '---'
167
- ```
168
153
169
- ### Big Grids
170
154
171
- ![ Big Grids Example ] ( https://cdn.rawgit.com/blampe/goat/main/examples/big-grids.svg )
155
+ ```
172
156
157
+ ### Big Grids
173
158
```
174
159
.----. .----.
175
160
/ \ / \ .-----+-----+-----.
@@ -182,12 +167,12 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character,
182
167
'----+ +----+ + | | | | +-----+-----+-----+-----+
183
168
\ / \ / | A | | | / / / / /
184
169
'----' '----' '-----+-----+-----' '-----+-----+-----+-----+
185
- ```
186
170
187
- ### Complicated
188
171
189
- ![ Complicated Example] ( https://cdn.rawgit.com/blampe/goat/main/examples/complicated.svg )
172
+ ```
173
+ ![ ] ( ./examples/big-grids.svg )
190
174
175
+ ### Complicated
191
176
```
192
177
+-------------------+ ^ .---.
193
178
| A Box |__.--.__ __.--> | .-. | |
@@ -213,9 +198,31 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character,
213
198
.-. .---+--------. / A || B *bold* | ^
214
199
| | | Not a dot | <---+---<-- A dash--is not a line v |
215
200
'-' '---------+--' / Nor/is this. ---
201
+
216
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
217
220
218
- 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.
219
226
220
227
[ @bep ] : https://github.com/bep/goat/
221
228
[ @dmacvicar ] : https://github.com/dmacvicar/goat
0 commit comments