code: function prettifyXml(xmlInput, options = {}) {
    const {
      indent: indentOption = 2,
      newline: newlineOption = EOL,
    } = options
    const indentString = stringTimesN(indentOption, ' ')
  
    let formatted = ''
    const regex = /(>)(<)(\/*)/g
    const xml = xmlInput.replace(regex, `$1${newlineOption}$2$3`)
    let pad = 0
    xml.split(/\r?\n/).forEach(l => {
      const line = l.trim()
  
      let indent = 0
      if (line.match(/.+<\/\w[^>]*>$/)) {
        indent = 0
      } else if (line.match(/^<\/\w/)) {
        // Somehow istanbul doesn't see the else case as covered, although it is. Skip it.
        /* istanbul ignore else  */
        if (pad !== 0) {
          pad -= 1
        }
      } else if (line.match(/^<\w([^>]*[^\/])?>.*$/)) {
        indent = 1
      } else {
        indent = 0
      }
  
      const padding = stringTimesN(pad, indentString)
      formatted += padding + line + newlineOption // eslint-disable-line prefer-template
      pad += indent
    })
  
    return formatted.trim()
  }
docs: Adapted from https://gist.github.com/sente/1083506