ASCII アート図を SVG に変換するaasvgコマンドを使う

はじめに

AASVGに変換したいケースがあったのでaasvgコマンドを試してみる。
https://packages.ubuntu.com/noble/text/aasvg
https://github.com/martinthomson/aasvg

環境

Windows 11 Professional
WSL2 Ubuntu 24.04 LTS

aasvgのインストール

sudo apt-get install aasvg
ログ
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libcares2 libnode109 libuv1t64 node-acorn node-busboy node-cjs-module-lexer node-undici node-xtend nodejs nodejs-doc
Suggested packages:
  npm
The following NEW packages will be installed:
  aasvg libcares2 libnode109 libuv1t64 node-acorn node-busboy node-cjs-module-lexer node-undici node-xtend nodejs
  nodejs-doc
0 upgraded, 11 newly installed, 0 to remove and 59 not upgraded.
Need to get 16.2 MB of archives.
After this operation, 70.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu noble/main amd64 libuv1t64 amd64 1.48.0-1.1build1 [97.3 kB]
Get:2 http://archive.ubuntu.com/ubuntu noble/main amd64 libcares2 amd64 1.27.0-1.0ubuntu1 [73.7 kB]
Get:3 http://archive.ubuntu.com/ubuntu noble/universe amd64 node-xtend all 4.0.2-3 [3902 B]
Get:4 http://archive.ubuntu.com/ubuntu noble/universe amd64 node-acorn all 8.8.1+ds+~cs25.17.7-2 [115 kB]
Get:5 http://archive.ubuntu.com/ubuntu noble/universe amd64 node-cjs-module-lexer all 1.2.3+dfsg-1 [32.1 kB]
Get:6 http://archive.ubuntu.com/ubuntu noble/universe amd64 node-busboy all 1.6.0+~cs2.6.0-2 [17.3 kB]
Get:7 http://archive.ubuntu.com/ubuntu noble/universe amd64 node-undici all 5.26.3+dfsg1+~cs23.10.12-2 [325 kB]
Get:8 http://archive.ubuntu.com/ubuntu noble/universe amd64 libnode109 amd64 18.19.1+dfsg-6ubuntu5 [11.6 MB]
Get:9 http://archive.ubuntu.com/ubuntu noble/universe amd64 nodejs amd64 18.19.1+dfsg-6ubuntu5 [306 kB]
Get:10 http://archive.ubuntu.com/ubuntu noble/universe amd64 aasvg all 0.3.2-1 [20.7 kB]
Get:11 http://archive.ubuntu.com/ubuntu noble/universe amd64 nodejs-doc all 18.19.1+dfsg-6ubuntu5 [3552 kB]
Fetched 16.2 MB in 3s (5129 kB/s)
Selecting previously unselected package libuv1t64:amd64.
(Reading database ... 49987 files and directories currently installed.)
Preparing to unpack .../00-libuv1t64_1.48.0-1.1build1_amd64.deb ...
Unpacking libuv1t64:amd64 (1.48.0-1.1build1) ...
Selecting previously unselected package libcares2:amd64.
Preparing to unpack .../01-libcares2_1.27.0-1.0ubuntu1_amd64.deb ...
Unpacking libcares2:amd64 (1.27.0-1.0ubuntu1) ...
Selecting previously unselected package node-xtend.
Preparing to unpack .../02-node-xtend_4.0.2-3_all.deb ...
Unpacking node-xtend (4.0.2-3) ...
Selecting previously unselected package node-acorn.
Preparing to unpack .../03-node-acorn_8.8.1+ds+~cs25.17.7-2_all.deb ...
Unpacking node-acorn (8.8.1+ds+~cs25.17.7-2) ...
Selecting previously unselected package node-cjs-module-lexer.
Preparing to unpack .../04-node-cjs-module-lexer_1.2.3+dfsg-1_all.deb ...
Unpacking node-cjs-module-lexer (1.2.3+dfsg-1) ...
Selecting previously unselected package node-busboy.
Preparing to unpack .../05-node-busboy_1.6.0+~cs2.6.0-2_all.deb ...
Unpacking node-busboy (1.6.0+~cs2.6.0-2) ...
Selecting previously unselected package node-undici.
Preparing to unpack .../06-node-undici_5.26.3+dfsg1+~cs23.10.12-2_all.deb ...
Unpacking node-undici (5.26.3+dfsg1+~cs23.10.12-2) ...
Selecting previously unselected package libnode109:amd64.
Preparing to unpack .../07-libnode109_18.19.1+dfsg-6ubuntu5_amd64.deb ...
Unpacking libnode109:amd64 (18.19.1+dfsg-6ubuntu5) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../08-nodejs_18.19.1+dfsg-6ubuntu5_amd64.deb ...
Unpacking nodejs (18.19.1+dfsg-6ubuntu5) ...
Selecting previously unselected package aasvg.
Preparing to unpack .../09-aasvg_0.3.2-1_all.deb ...
Unpacking aasvg (0.3.2-1) ...
Selecting previously unselected package nodejs-doc.
Preparing to unpack .../10-nodejs-doc_18.19.1+dfsg-6ubuntu5_all.deb ...
Unpacking nodejs-doc (18.19.1+dfsg-6ubuntu5) ...
Setting up libuv1t64:amd64 (1.48.0-1.1build1) ...
Setting up node-cjs-module-lexer (1.2.3+dfsg-1) ...
Setting up libcares2:amd64 (1.27.0-1.0ubuntu1) ...
Setting up nodejs-doc (18.19.1+dfsg-6ubuntu5) ...
Setting up node-xtend (4.0.2-3) ...
Setting up node-busboy (1.6.0+~cs2.6.0-2) ...
Setting up node-undici (5.26.3+dfsg1+~cs23.10.12-2) ...
Setting up node-acorn (8.8.1+ds+~cs25.17.7-2) ...
Setting up libnode109:amd64 (18.19.1+dfsg-6ubuntu5) ...
Setting up nodejs (18.19.1+dfsg-6ubuntu5) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
Setting up aasvg (0.3.2-1) ...
Processing triggers for libc-bin (2.39-0ubuntu8.3) ...
Processing triggers for man-db (2.12.0-4build2) ...

aasvgを使う

man aasvg
ログ
       --grid Draw a grid (debugging)

       --spaces=<n>
              Split text after <n> spaces [default: 2] (0 means place every character separately)

       --stretch
              Stretch text to better fit it (use with --spaces > 0; uses advanced SVG)

       --fill Omit width and height attributes

       --width=<n>
              Set the viewbox width to <n> characters

       --height=<n>
              Set the viewbox height to <n> characters

       --backdrop
              Draw a backdrop

       --source
              Draw an overlay with source text

       --<attr>=<value>
              Set SVG attribute <attr> to <value>

       --version
              Show the version and exit

aasvg < example.txt > example.svg

https://raw.githubusercontent.com/martinthomson/aasvg/refs/heads/main/example.txt を使ってみる。

成果物

A Box<-Round|^Mixed RoundedDiagonals& Square CornersSearchInteriorDiag lineif (a > b)Curved lineobj->fcn()Done?JoinCurvedVertical3not:line'quotes'|A || B*bold*Not a dot=<A dash--is not a lineNor/is this.~~~>=~~~>-=~~~~~~~~-=<~~~<<~~~

参考

おわりに

AASVGに変換するaasvgコマンドを使ってみた。
AAを別の形式にしたいなと思った時があるので、今後も使ってみよう。

Hugo で構築されています。
テーマ StackJimmy によって設計されています。