def escape.rev

gralha-xml-doc@0.1.0.1 · xml.bend:416

import gralha-xml-doc@0.1.0.1/xml.bend as Xml
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U

416# Build escaped XML in reverse, so large data URIs do not grow the host stack.
417def escape.rev(s: String, acc: String) -> String:
418  match s:
419    case SNil{}: acc
420    case SCon{Chr{c}, t}:
421      +ch = c
422      escape.rev(t, U.rev(U.choose(String, U32.is_eq(ch, 38), "&",
423        U.choose(String, U32.is_eq(ch, 60), "<",
424          U.choose(String, U32.is_eq(ch, 62), ">",
425            U.choose(String, U32.is_eq(ch, 34), """, SCon{Chr{ch}, ""})))), acc))

Uses (5)

Used by (3)