def image.svg.wellformed

gralha-svg-render@0.1.0.1 · svg.bend:3759

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

3759def image.svg.wellformed(+tokens: List<&2, XML.Token>, +stack: List<&2, String>, +seen: Bool) -> Bool:
3760  match tokens stack:
3761    case Nil{} Nil{}: seen
3762    case Nil{} Con{head, tail}: False{}
3763    case Con{XML.Chars{content}, rest} stack:
3764      (Bool.not(image.svg.stack.empty(stack)) || U.string.equal(U.trim.both(content), "")) && image.svg.wellformed(rest, stack, seen)
3765    case Con{XML.Open{name, attrs, closed}, rest} stack:
3766      +top = image.svg.stack.empty(stack)
3767      U.branch(Bool, Bool.not(top) || (Bool.not(seen) && U.string.equal(name, "svg")),
3768        _ => image.svg.wellformed(rest, U.choose(List<&2, String>, closed, stack, Con{name, stack}), seen || top), _ => False{})
3769    case Con{XML.Shut{name}, rest} Nil{}: False{}
3770    case Con{XML.Shut{name}, rest} Con{head, tail}:
3771      U.string.equal(U.trim.both(name), head) && image.svg.wellformed(rest, tail, seen)

Uses (12)

Used by (1)