def entity

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

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

333# Decode XML entities before interpreting attributes or exposing source editing.
334def entity(+s: String) -> String:
335  U.branch(String, U.string.equal(s, "amp"), _ => "&",
336    _ => U.branch(String, U.string.equal(s, "lt"), _ => "<",
337      _ => U.branch(String, U.string.equal(s, "gt"), _ => ">",
338        _ => U.branch(String, U.string.equal(s, "quot"), _ => "\"",
339          _ => U.branch(String, U.string.equal(s, "apos"), _ => "'",
340            _ => U.branch(String, U.prefix(s, "#x"), _ => SCon{Chr{U.hex(U.drop(s, "#x"), 0)}, ""},
341              _ => U.branch(String, U.prefix(s, "#"), _ => SCon{Chr{F32.to_u32(U.scalar(U.drop(s, "#"), 65533.0))}, ""},
342                _ => "&" ++ s ++ ";")))))))

Uses (10)

Used by (1)