MCPcopy Index your code
hub / github.com/HenrikJoreteg/html-parse-stringify / stringify

Function stringify

src/stringify.js:12–30  ·  view source on GitHub ↗
(buff, doc)

Source from the content-addressed store, hash-verified

10}
11
12function stringify(buff, doc) {
13 switch (doc.type) {
14 case 'text':
15 return buff + doc.content
16 case 'tag':
17 buff +=
18 '<' +
19 doc.name +
20 (doc.attrs ? attrString(doc.attrs) : '') +
21 (doc.voidElement ? '/>' : '>')
22 if (doc.voidElement) {
23 return buff
24 }
25 return buff + doc.children.reduce(stringify, '') + '</' + doc.name + '>'
26 case 'comment':
27 buff += '<!--' + doc.comment + '-->'
28 return buff
29 }
30}
31
32export default function (doc) {
33 return doc.reduce(function (token, rootEl) {

Callers 1

stringify.jsFile · 0.70

Calls 1

attrStringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…