MCPcopy Create free account
hub / github.com/svg/svgo / stringifyNode

Function stringifyNode

lib/stringifier.js:106–132  ·  view source on GitHub ↗
(data, config, state)

Source from the content-addressed store, hash-verified

104 * @returns {string}
105 */
106const stringifyNode = (data, config, state) => {
107 let svg = '';
108 state.indentLevel++;
109 for (const item of data.children) {
110 switch (item.type) {
111 case 'element':
112 svg += stringifyElement(item, config, state);
113 break;
114 case 'text':
115 svg += stringifyText(item, config, state);
116 break;
117 case 'doctype':
118 svg += stringifyDoctype(item, config);
119 break;
120 case 'instruction':
121 svg += stringifyInstruction(item, config);
122 break;
123 case 'comment':
124 svg += stringifyComment(item, config);
125 break;
126 case 'cdata':
127 svg += stringifyCdata(item, config, state);
128 }
129 }
130 state.indentLevel--;
131 return svg;
132};
133
134/**
135 * Create indent string in accordance with the current node level.

Callers 2

stringifySvgFunction · 0.85
stringifyElementFunction · 0.85

Calls 6

stringifyElementFunction · 0.85
stringifyTextFunction · 0.85
stringifyDoctypeFunction · 0.85
stringifyInstructionFunction · 0.85
stringifyCommentFunction · 0.85
stringifyCdataFunction · 0.85

Tested by

no test coverage detected