%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/emergentqj/actioncivile/pre-auth/.4cc3a2e1590a4463a5f392ddcc26929e/static/node_modules/html-parse-stringify/src/
Upload File :
Create Path :
Current File : /home/emergentqj/actioncivile/pre-auth/.4cc3a2e1590a4463a5f392ddcc26929e/static/node_modules/html-parse-stringify/src/stringify.js

function attrString(attrs) {
  const buff = []
  for (let key in attrs) {
    buff.push(key + '="' + attrs[key] + '"')
  }
  if (!buff.length) {
    return ''
  }
  return ' ' + buff.join(' ')
}

function stringify(buff, doc) {
  switch (doc.type) {
    case 'text':
      return buff + doc.content
    case 'tag':
      buff +=
        '<' +
        doc.name +
        (doc.attrs ? attrString(doc.attrs) : '') +
        (doc.voidElement ? '/>' : '>')
      if (doc.voidElement) {
        return buff
      }
      return buff + doc.children.reduce(stringify, '') + '</' + doc.name + '>'
    case 'comment':
      buff += '<!--' + doc.comment + '-->'
      return buff
  }
}

export default function (doc) {
  return doc.reduce(function (token, rootEl) {
    return token + stringify('', rootEl)
  }, '')
}

Zerion Mini Shell 1.0