MCPcopy Index your code
hub / github.com/microsoft/SandDance / markup

Function markup

docs/app/js/sanddance-app.js:124000–124030  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

123998const innerText = (val)=>(val + "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
123999const attrText = (val)=>innerText(val).replace(/"/g, "&quot;").replace(/\t/g, "&#x9;").replace(/\n/g, "&#xA;").replace(/\r/g, "&#xD;");
124000function markup() {
124001 let buf = "", outer = "", inner = "";
124002 const stack = [], clear = ()=>outer = inner = "", push = (tag)=>{
124003 if (outer) {
124004 buf += `${outer}>${inner}`;
124005 clear();
124006 }
124007 stack.push(tag);
124008 }, attr3 = (name, value8)=>{
124009 if (value8 != null) outer += ` ${name}="${attrText(value8)}"`;
124010 return m;
124011 }, m = {
124012 open (tag, ...attrs) {
124013 push(tag);
124014 outer = "<" + tag;
124015 for (const set of attrs)for(const key in set)attr3(key, set[key]);
124016 return m;
124017 },
124018 close () {
124019 const tag = stack.pop();
124020 if (outer) buf += outer + (inner ? `>${inner}</${tag}>` : "/>");
124021 else buf += `</${tag}>`;
124022 clear();
124023 return m;
124024 },
124025 attr: attr3,
124026 text: (t)=>(inner += innerText(t), m),
124027 toString: ()=>buf
124028 };
124029 return m;
124030}
124031const serializeXML = (node)=>_serialize(markup(), node) + "";
124032function _serialize(m, node) {
124033 m.open(node.tagName);

Callers 2

serializeXMLFunction · 0.70
_renderFunction · 0.70

Calls 1

innerTextFunction · 0.70

Tested by

no test coverage detected