This plugin eases the inclusion of images produced by the Aysmptote tool.

The asy tool must be installed to use this plugin. Moreover, to produce SVG output, the dvisvgm tool must be installed too.

Usage:

$ stog --package stog.asy ...

This plugin adds a new base rule <asy>. Here are the possible ways to use it:

CodeResult
Output to asy.svg, using an <img> node to show the image:
void testline(real y) { draw((0,y)--(100,y),currentpen+solid); draw((0,y-10)--(100,y-10),currentpen+dotted); draw((0,y-20)--(100,y-20),currentpen+Dotted()); draw((0,y-30)--(100,y-30),currentpen+dashed); draw((0,y-40)--(100,y-40),currentpen+longdashed); draw((0,y-50)--(100,y-50),currentpen+dashdotted); draw((0,y-60)--(100,y-60),currentpen+longdashdotted); } currentpen=linewidth(0.5); testline(100); currentpen=linewidth(4); testline(0); ]]>
<asy outfile="asy1.svg">
void testline(real y) {
  draw((0,y)--(100,y),currentpen+solid);
  draw((0,y-10)--(100,y-10),currentpen+dotted);
  draw((0,y-20)--(100,y-20),currentpen+Dotted());
  draw((0,y-30)--(100,y-30),currentpen+dashed);
  draw((0,y-40)--(100,y-40),currentpen+longdashed);
  draw((0,y-50)--(100,y-50),currentpen+dashdotted);
  draw((0,y-60)--(100,y-60),currentpen+longdashdotted);
}

currentpen=linewidth(0.5);
testline(100);
currentpen=linewidth(4);
testline(0);
</asy>
Output a png file to asy2.png and read source from code2.asy:
]]>
<asy src="code2.asy"
  type="png" outfile="asy2.png"
  width="200px"/>
With code2.asy. The additional attributes (here width) are passed to the <img> node.
With <doc-...> rules to get labels, using attribute defer_="1" in the <asy> so that rewriting is performed in its children before the code is being passed to asymptote:
real margin=1.5mm; object left=align( object("", ellipse,margin),W); add(left); object right=align( object("", ellipse,margin),4E); add(right); add(new void(frame f, transform t) { draw(f,point(left,NE,t)--point(right,W,t)); }); ]]>
<asy defer_="1">
real margin=1.5mm;
object left=align(
  object("<doc-title doc-path="plugins/asy"/>",
         ellipse,margin),W);
add(left);
object right=align(
  object("<doc-title doc-path="plugins"/>",
         ellipse,margin),4E);
add(right);
add(new void(frame f, transform t) {
    draw(f,point(left,NE,t)--point(right,W,t));
  });
</asy>
Since no outfile attribute is given, the svg file produced is included (no use of <img>).
Including again the produced svg file. To avoid conflicts in ids, we use the prefix-svg-ids="foo" attribute:
]]>
<asy prefix-svg-ids="foo" src="code4.asy"/>
With code4.asy.
The contents of the args attribute is used as additional argument to the command which is run:
]]>
<asy prefix-svg-ids="bar"
  args="-gray"
  src="code4.asy"/>
With code4.asy.