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