<commit_before>import {escape} from './escape.js'
import {tokenTypes} from './html.js'

const selfClosing = [
  'area',
  'base',
  'br',
  'col',
  'embed',
  'hr',
  'img',
  'input',
  'link',
  'meta',
  'param',
  'source',
  'track',
  'wbr'
]

export const stringify = (obj) => {
  const {tag, attributes, children, variables} = obj

  let result = `<${tag}`
  const isSelfClosing = selfClosing.includes(tag)

  const reducedAttributes = Array.from({
    *[Symbol.iterator]() {
      for (const attribute of attributes) {
        if (attribute.key) {
          if (attribute.key.startsWith('@')) continue

          const hasColon = attribute.key.startsWith(':')

          if (hasColon) {
            attribute.key = attribute.key.substring(1)
          }

          yield attribute
        } else {
          for (let key of Object.keys(variables[attribute.value])) {
            if (key.startsWith('@')) continue

            const hasColon = key.startsWith(':')

            if (hasColon) {
              key = key.substring(1)
            }

            yield {key, value: variables[attribute.value][key]}
          }
        }
      }
    }
  })

  for (const attr of reducedAttributes) {
    let value = attr.value
<commit_msg>Change stringify<commit_after>import {escape} from './escape.js'
import {tokenTypes} from './html.js'

const selfClosing = [
  'area',
  'base',
  'br',
  'col',
  'embed',
  'hr',
  'img',
  'input',
  'link',
  'meta',
  'param',
  'source',
  'track',
  'wbr'
]

export const stringify = (obj) => {
  const {tag, attributes, children, variables} = obj

  let result = `<${tag}`
  const isSelfClosing = selfClosing.includes(tag)

  const reducedAttributes = []

  for (let i = 0; i < attributes.length; i++) {
    const attribute = attributes[i]

    if (attribute.key) {
      if (attribute.key.startsWith('@')) continue

      const hasColon = attribute.key.startsWith(':')

      if (hasColon) {
        attribute.key = attribute.key.substring(1)
      }

      reducedAttributes.push(attribute)
    } else {
      for (let key of Object.keys(variables[attribute.value])) {
        if (key.startsWith('@')) continue

        const hasColon = key.startsWith(':')

        if (hasColon) {
          key = key.substring(1)
        }

        reducedAttributes.push({key, value: variables[attribute.value][key]})
      }
    }
  }

  for (const attr of reducedAttributes) {
    let value = attr.value

{'fraction_non_alphanumeric': 0.1518624641833811, 'fraction_numerical': 0.002046663937781416, 'mean_word_length': 2.361760660247593, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '708047', 'n_tokens_mistral': 799, 'n_tokens_neox': 787, 'n_words': 184}