-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdemo.txt
448 lines (391 loc) · 17 KB
/
demo.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
====== a2s Plugin ======
a2s is a little plugin that turns ASCII art boxes, lines and arrows into nice SVG images. It is based on [[https://github.com/dhobsd/asciitosvg|ASCIIToSVG]] by [[https://github.com/dhobsd|Devon H. O'Dell]]. It is very similar to the [[doku>plugin:ditaa|ditaa]] plugin but does not require external programs to run. It is compatible with the ODT export plugin.
===== Installation =====
Install the plugin using the [[doku>plugin:plugin|Plugin Manager]]. It will install the latest version of the plugin. Refer to [[doku>:Plugins]] on how to install plugins manually.
===== Examples/Usage =====
<a2s>
.-------------------------.
|[Logo] |
| .---.-. .-----. .-----. |
| | .-. | +--> | | <--| |
| | '-' | | <--| +--> | |
| '---'-' '-----' '-----' |
| ascii 2 svg |
| |
'-------------------------'
https://9vx.org/~dho/a2s/
[Logo]: {"fill":"#88d","a2s:delref":true}
</a2s>
<code txt logo.a2s>
<a2s>
.-------------------------.
|[Logo] |
| .---.-. .-----. .-----. |
| | .-. | +--> | | <--| |
| | '-' | | <--| +--> | |
| '---'-' '-----' '-----' |
| ascii 2 svg |
| |
'-------------------------'
https://9vx.org/~dho/a2s/
[Logo]: {"fill":"#88d","a2s:delref":true}
</a2s>
</code>
<a2s>
+----+--------+ :
| | | .----------------. |
v | | |[0] | |
#---------+---. | o----+----> Waow ! | v
| |<---+ / | | ^
====>| Hello | / '----------------' |
====>| (svg) World '------. / #------# .-------. |
| .-----# |==+ | | | | |
'----# '---------# #------# '-------'
[0]: {"a2s:link":"https://github.com/schplurtz/a2s","fill":"#CE3B83","stroke":"#F50078","stroke-dasharray":"5 5","stroke-width":4,"a2s:type":"cloud","a2s:delref":true}
</a2s>
<code txt tryme.a2s>
<a2s>
+----+--------+ :
| | | .----------------. |
v | | |[0] | |
#---------+---. | o----+----> Waow ! | v
| |<---+ / | | ^
====>| Hello | / '----------------' |
====>| (svg) World '------. / #------# .-------. |
| .-----# |==+ | | | | |
'----# '---------# #------# '-------'
[0]: {"a2s:link":"https://github.com/schplurtz/a2s","fill":"#CE3B83","stroke":"#F50078","stroke-dasharray":"5 5","stroke-width":4,"a2s:type":"cloud","a2s:delref":true}
</a2s>
</code>
===== Syntax =====
Please, note that the reference doc is on [[https://github.com/dhobsd/asciitosvg/|ASCIIToSVG site]].
* There are two kinds of objects : free lines, and closed shapes (usually boxes)
* free lines
* Plain straight lines are drawn with ''|'', ''-'', ''\'' and ''/''
* dashed lines : use at least one ''='' (horizontal) or '':'' (vertical) in a line, and it is dashed. Oblique lines can't be dashed.
* ''+'' and ''o'' (lower case letter O) are used to connect lines of different orientation.
* arrowhead. Use ''<'', ''>'', ''v'', and ''^''. Nothing special here
* closed shapes
* Borders are drawn with ''|'' and ''-'' only.
* ''%%'%%'', ''.'' and ''#'' are used for box angle. Do not use ''+'', as it does not create closed shape.
* closed shape can be styled.
- Identify the shape : In the **top left** angle of the shape, put some text between square bracket. example ''[0]'', ''[logo]'', ''[some text]''
- **At the bottom** of the drawing, for each identified shape, add a **single** line with the identifier and a JSON hash of property:value. See the section just below for details.
==== Styling shapes and linking ====
Colors are expressed either
* In RGB with 3 or 6 hexdigits preceded by a sharp sign : ''#88d'', ''#F50078''
* or using a colorname such as ''blue'', ''red'', ''LemonChiffon'' etc... I just don't know the exact list of valid colornames. Please note that ''LemonChiffon'' seems valid, but that ''lemon chiffon'' is not, although it is a valid X11 colorname.
It is not possible to choose text color. When background is dark, ASCIIToSVG
uses white. When background is light, text is written in black.
Available styling parametre :
* fill color : ''"fill":"//color//"''. examples :<code>"fill":"#88d"
"fill":"#F50078"
"fill":"LemonChiffon"
"fill":"blue"
</code>
* border stroke color : ''"stroke":"//color//"''. examples :<code>"stroke":"#88d"
"stroke":"#F50078"
"stroke":"LemonChiffon"
"stroke":"blue"
</code>
* border stroke width : ''"stroke-width"://number//'' unit and default value is unknown. Example :<code>"stroke-width":7</code>
* border stroke dash : A serie of pair of dash length and space length. Length unit is unknown. Examples <code>"stroke-dasharray":"5 5"
"stroke-dasharray":"5 5 10 3 2 8"
</code>
* shape : ''"a2s:type":"shapename"'' where shapename is one of ''cloud'', ''computer'', ''diamond'', ''document'', ''storage'', ''printer''. Examples<code>"a2s:type":"cloud"
"a2s:type":"storage"
</code>
* link : ''"a2s:link":"//linktext//"'' where //linktext// is either an internal wiki link, an [[doku>interwiki|interwiki link]], or a classic //%%protocol://server/resource%%// link. Since SVG can be included in ODT and PDF file, a2s does not obey the [[doku>config:canonical|canonical]] setting and always generate absolute links. Since neither libreoffice nor [[doku>plugin:dw2pdf|dw2pdf]] use this link, this seems rather useless and may change in the future.\\ Examples:<code>
"a2s:link":"[[.:]]"
"a2s:link":"[[:start]]"
"a2s:link":"[[:start|The start page]]"
"a2s:link":"[[doku>interwiki|interwiki link]]
"a2s:link":"https://github.com/schplurtz/a2s"
"a2s:link":"ftp://ftp.debian.org/debian/README"
</code>
* identifier removal. By default the id is left in the image. This is useful when you have enough room to use a meaningful word as id. However, it is possible to remove it using this code <code>"a2s:delref":true</code>
here is a full example :
<code>[0]: {"fill":"#d48","stroke":"#F50078","stroke-dasharray":"5 5","stroke-width":4,"a2s:type":"cloud","a2s:delref":true,"a2s:link":"https://github.com/schplurtz/a2s"}</code>
==== Alignment ====
Just like with regular images, you can align your SVG graphics by inserting spaces after ''<'' and before ''>''. If there are more spaces on the left of the word ''a2s'', then the image is right-aligned, if there are more spaces on the right, the image is left-aligned. When there is the same number of spaces on both sides of ''a2s'', the image is centered
< a2s>
.---------.
|[1] |
| .-----. |
| | <--+ |
| +--> | |
| '-----' |
| svg |
|< a2s>|
'---------'
[1]: {"fill":"#E97B11","a2s:delref":true}
</a2s>
<a2s >
.---------.
|[blue] |
| .---.-. |
| | .-. | |
| | '-' | |
| '---'-' |
| ascii |
|<a2s >|
'---------'
[blue]: {"fill":"blue","a2s:delref":true}
</a2s>
< a2s >
.---------.
|[lc] |
| .-----. |
| +--> | |
| | <--+ |
| '-----' |
| 2 |
|< a2s >|
'---------'
[lc]: {"fill":"LemonChiffon","a2s:delref":true}
</a2s>
< a2s>
.---------.
|[1] |
| .-----. |
| | <--+ |
| +--> | |
| '-----' |
| svg |
|< a2s>|
'---------'
[1]: {"fill":"#bcd2ee","a2s:delref":true}
</a2s>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed accumsan nec
odio quis aliquet. Nulla gravida ac est venenatis rhoncus. Aenean viverra
felis semper turpis commodo, ut vehicula dui mattis. Vivamus malesuada
vulputate justo. Suspendisse potenti. Etiam porttitor elementum nulla in
ultricies. Vestibulum volutpat nibh eu faucibus scelerisque. Suspendisse
eleifend arcu neque, at tristique metus tempus semper. Nullam ante leo,
convallis sit amet accumsan sed, semper nec quam. Curabitur fringilla,
orci id scelerisque varius, enim est ultrices est, et elementum magna
metus sit amet eros. Sed pharetra semper ligula sit amet efficitur. Mauris
congue accumsan egestas. Suspendisse potenti. Curabitur tincidunt
metus non justo tempus lacinia. Donec ornare velit a massa semper
ullamcorper. Donec dapibus ante vel lacus efficitur sodales. Integer
pretium eleifend nulla, at ullamcorper ipsum pellentesque placerat. Cras
condimentum iaculis leo. Sed sit amet pretium sem, sit amet suscipit
nibh. Nulla congue molestie purus sed congue. Fusce tincidunt ipsum
id molestie pellentesque. Curabitur lobortis placerat risus eget
vulputate. Maecenas ac feugiat ex, at facilisis nulla. Etiam rutrum
quis eros et facilisis. Nulla sodales molestie odio, id egestas massa
aliquam vel. Mauris vulputate ante sed volutpat euismod. Sed eleifend,
urna vitae auctor consequat, dui felis elementum ex, ut laoreet nunc
nisl convallis mi. Nullam id bibendum justo.
<code>
< a2s>
.---------.
|[1] |
| .-----. |
| | <--+ |
| +--> | |
| '-----' |
| svg |
|< a2s>|
'---------'
[1]: {"fill":"#E97B11","a2s:delref":true}
</a2s>
<a2s >
.---------.
|[blue] |
| .---.-. |
| | .-. | |
| | '-' | |
| '---'-' |
| ascii |
|<a2s >|
'---------'
[blue]: {"fill":"blue","a2s:delref":true}
</a2s>
< a2s >
.---------.
|[lc] |
| .-----. |
| +--> | |
| | <--+ |
| '-----' |
| 2 |
|< a2s >|
'---------'
[lc]: {"fill":"LemonChiffon","a2s:delref":true}
</a2s>
< a2s>
.---------.
|[1] |
| .-----. |
| | <--+ |
| +--> | |
| '-----' |
| svg |
|< a2s>|
'---------'
[1]: {"fill":"#bcd2ee","a2s:delref":true}
</a2s>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed accumsan nec
odio quis aliquet. Nulla gravida ac est venenatis rhoncus. Aenean viverra
felis semper turpis commodo, ut vehicula dui mattis. Vivamus malesuada
vulputate justo. Suspendisse potenti. Etiam porttitor elementum nulla in
ultricies. Vestibulum volutpat nibh eu faucibus scelerisque. Suspendisse
eleifend arcu neque, at tristique metus tempus semper. Nullam ante leo,
convallis sit amet accumsan sed, semper nec quam. Curabitur fringilla,
orci id scelerisque varius, enim est ultrices est, et elementum magna
metus sit amet eros. Sed pharetra semper ligula sit amet efficitur. Mauris
congue accumsan egestas. Suspendisse potenti. Curabitur tincidunt
metus non justo tempus lacinia. Donec ornare velit a massa semper
ullamcorper. Donec dapibus ante vel lacus efficitur sodales. Integer
pretium eleifend nulla, at ullamcorper ipsum pellentesque placerat. Cras
condimentum iaculis leo. Sed sit amet pretium sem, sit amet suscipit
nibh. Nulla congue molestie purus sed congue. Fusce tincidunt ipsum
id molestie pellentesque. Curabitur lobortis placerat risus eget
vulputate. Maecenas ac feugiat ex, at facilisis nulla. Etiam rutrum
quis eros et facilisis. Nulla sodales molestie odio, id egestas massa
aliquam vel. Mauris vulputate ante sed volutpat euismod. Sed eleifend,
urna vitae auctor consequat, dui felis elementum ex, ut laoreet nunc
nisl convallis mi. Nullam id bibendum justo.
</code>
===== list of known SVG shapes =====
<a2s>
Shapes :
.----------. .----------. .----------.
|[cloud] | |[computer]| |[diamond] |
| | +->| |<-o->| |
| | | | | | | |
.----------. | .----------. | .----------.
--------------o----------------+
.----------. | .----------. | .----------.
|[document]| : |[storage] | | |[printer] |
| |<-+->| | | | Some txt |
| | | |<-+->| |
.----------. .----------. '----------'
.----------. .----------. .----------.
|[cl] | |[c] | |[yn] |
| | +->| |<-o->| |
| | | | | | | |
.----------. | .----------. | .----------.
--------------o----------------+
.----------. | .----------. | .----------.
|[d] | : |[st] | | |[p] |
| |<-+->| | | | Some txt |
| | | |<-+->| |
.----------. .----------. '----------'
[printer]: {"a2s:type":"printer","fill":"#ff1493"}
[computer]: {"a2s:type":"computer"}
[cloud]: {"a2s:type":"cloud"}
[diamond]: {"a2s:type":"diamond"}
[document]: {"a2s:type":"document"}
[storage]: {"a2s:type":"storage"}
[p]: {"a2s:type":"printer","fill":"#ff1493","a2s:delref":true}
[c]: {"a2s:type":"computer","a2s:delref":true}
[cl]: {"a2s:type":"cloud","a2s:delref":true}
[yn]: {"a2s:type":"diamond","a2s:delref":true}
[d]: {"a2s:type":"document","a2s:delref":true}
[st]: {"a2s:type":"storage","a2s:delref":true}
</a2s>
<code txt shapes>
<a2s>
Shapes :
.----------. .----------. .----------.
|[cloud] | |[computer]| |[diamond] |
| | +->| |<-o->| |
| | | | | | | |
.----------. | .----------. | .----------.
--------------o----------------+
.----------. | .----------. | .----------.
|[document]| : |[storage] | | |[printer] |
| |<-+->| | | | Some txt |
| | | |<-+->| |
.----------. .----------. '----------'
.----------. .----------. .----------.
|[cl] | |[c] | |[yn] |
| | +->| |<-o->| |
| | | | | | | |
.----------. | .----------. | .----------.
--------------o----------------+
.----------. | .----------. | .----------.
|[d] | : |[st] | | |[p] |
| |<-+->| | | | Some txt |
| | | |<-+->| |
.----------. .----------. '----------'
[printer]: {"a2s:type":"printer","fill":"#ff1493"}
[computer]: {"a2s:type":"computer"}
[cloud]: {"a2s:type":"cloud"}
[diamond]: {"a2s:type":"diamond"}
[document]: {"a2s:type":"document"}
[storage]: {"a2s:type":"storage"}
[p]: {"a2s:type":"printer","fill":"#ff1493","a2s:delref":true}
[c]: {"a2s:type":"computer","a2s:delref":true}
[cl]: {"a2s:type":"cloud","a2s:delref":true}
[yn]: {"a2s:type":"diamond","a2s:delref":true}
[d]: {"a2s:type":"document","a2s:delref":true}
[st]: {"a2s:type":"storage","a2s:delref":true}
</a2s>
</code>
===== shapes inside shapes and custom styles =====
Transparency is obtained by using an invalid colorname.
This is undocumented. This may change depending on the browser
or rendering library.
<a2s>
.---------------------------. .----------.
|[storage] | |[document]|
| STORAGE | | |
| | | |
| | .----------.
| .----------. .---+-------.
| |[document]| |[0]|TRANS |
| | | | |PARENT |
| | | '---+-------'
| .----------. |
.---------------------------.
storage: : document :
"fill":"#a7ffbe" : "stroke":"#d627d8"
"a2s:delref":true : "stroke-width":9
: "stroke-dasharray":"5 3 3 7 10 5"
5 3 3 7 10 5
.-----. .---. .---. .-------. .----------. .-----.
|[r] | | | |[r]| | | |[r] | | |
'-----' '---' '---' '-------' '----------' '-----'
[document]: {"a2s:type":"document","stroke":"#d627d8","stroke-width":9,"stroke-dasharray":"5 3 3 7 10 5"}
[storage]: {"a2s:type":"storage","fill":"#a7ffbe","a2s:delref":true}
[0]: {"stroke":"#FFEE49","stroke-width":9,"a2s:delref":true,"fill":"caramba"}
[r]: {"fill":"#d627d8","a2s:delref":true}
</a2s>
<code>
<a2s>
.---------------------------. .----------.
|[storage] | |[document]|
| STORAGE | | |
| | | |
| | .----------.
| .----------. .---+-------.
| |[document]| |[0]|TRANS |
| | | | |PARENT |
| | | '---+-------'
| .----------. |
.---------------------------.
storage: : document :
"fill":"#a7ffbe" : "stroke":"#d627d8"
"a2s:delref":true : "stroke-width":9
: "stroke-dasharray":"5 3 3 7 10 5"
5 3 3 7 10 5
.-----. .---. .---. .-------. .----------. .-----.
|[r] | | | |[r]| | | |[r] | | |
'-----' '---' '---' '-------' '----------' '-----'
[document]: {"a2s:type":"document","stroke":"#d627d8","stroke-width":9,"stroke-dasharray":"5 3 3 7 10 5"}
[storage]: {"a2s:type":"storage","fill":"#a7ffbe","a2s:delref":true}
[0]: {"stroke":"#FFEE49","stroke-width":9,"a2s:delref":true,"fill":"caramba"}
[r]: {"fill":"#d627d8","a2s:delref":true}
</a2s>
</code>
===== Configuration and Settings =====
There is nothing to configure.
===== Development =====
=== Change Log ===
{{rss>https://github.com/schplurtz/a2s/commits/master.atom date}}
===== FAQ =====
:?: When I export to pdf with [[dw2pdf]], the arrowheads on line are not drawn, and alignment is not respected. Can you/I do something about that ?\\
:!: No. As of 2017/07/27, unless you are the a developer of dw2pdf or mpdf, its PDF library, there is nothing to do. Sorry.