def paint.order.normalize

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

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

1919# Normalize the small CSS paint-order vocabulary; omitted operations follow in
1920# default fill/stroke/markers order. Invalid values retain the inherited order.
1921def paint.order.normalize(s: String, +out: String, +gap: Bool) -> String:
1922  match s:
1923    case SNil{}: out
1924    case SCon{Chr{c}, rest}:
1925      +ch = c
1926      +tail = rest
1927      U.branch(String, U.space(ch), _ => paint.order.normalize(tail, out, Bool.not(U.string.equal(out, ""))),
1928        _ => paint.order.normalize(tail, out ++ U.choose(String, gap, " ", "") ++ SCon{Chr{ch}, SNil{}}, False{}))

Uses (9)

Used by (1)