def image.svg.expand
gralha-svg-render@0.1.0.1 · svg.bend:3900
import gralha-svg-render@0.1.0.1/svg.bend as Svg
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
import gralha-xml-doc@0.1.0.1/xml.bend as XML
import gralha-css-style@0.1.0.1/css.bend as CSS
3900def image.svg.expand(+fuel: Nat, +xs: List<&2, XML.Element>, +w: F32, +h: F32) -> List<&2, XML.Element>:
3901 match fuel xs:
3902 case Zero{} _: Nil{}
3903 case Succ{d} Nil{}: Nil{}
3904 case Succ{d} Con{XML.Element{n, attrs, kids, txt}, rest}:
3905 +as = CSS.properties(attrs)
3906 +href = U.trim.both(XML.attr.get(as, "href", XML.attr.get(as, "xlink:href", "")))
3907 Con{U.branch(XML.Element, U.string.equal(n, "image") && image.svg.reference(href),
3908 _ => image.svg.node(as, image.svg.document(image.svg.read(image.svg.source(U.until(U.drop(href, "data:"), 44, "")))), nodes => iw => ih => image.svg.expand(d, nodes, iw, ih)),
3909 _ => XML.Element{n, attrs, image.svg.expand(fuel, kids, w, h), txt}), image.svg.expand(fuel, rest, w, h)}