<commit_before>{Node} = require './node'

class EmptyElement extends Node
  constructor: ({ level, @name }) ->
    super { level }

  @parse: (level, node) ->
    m = node.match /^<\/(\S+)$/
    if m?
      new EmptyElement { level, name: m[1] }

  append: (prev) ->
    if @level > prev.level
      prev.appendChild @
    else if @level is prev.level
      prev.appendSibling @
    else if @level < prev.level
      p = prev
      p = p.parent until p.level is @level
      p.appendSibling @
    @

  write: ->
    indent = [0...@level].map((i) -> ' ').join ''
    aIndent = indent + '  ' # attrs is child
    attributes = ("#{aIndent}#{k}=\"#{v}\"\n" for k, v of @attributes).join ''
    attributes = if attributes.length > 0
      '\n' + attributes + aIndent
    else
      ' '
    children = @children.map((i) -> i.write()).join ''
    """
    #{indent}<#{@name}#{attributes}/>\n
    """

module.exports.EmptyElement = EmptyElement<commit_msg>remove unnecessary code<commit_after>{Node} = require './node'

class EmptyElement extends Node
  constructor: ({ level, @name }) ->
    super { level }

  @parse: (level, node) ->
    m = node.match /^<\/(\S+)$/
    if m?
      new EmptyElement { level, name: m[1] }

  append: (prev) ->
    if @level > prev.level
      prev.appendChild @
    else if @level is prev.level
      prev.appendSibling @
    else if @level < prev.level
      p = prev
      p = p.parent until p.level is @level
      p.appendSibling @
    @

  write: ->
    indent = [0...@level].map((i) -> ' ').join ''
    aIndent = indent + '  ' # attrs is child
    attributes = ("#{aIndent}#{k}=\"#{v}\"\n" for k, v of @attributes).join ''
    attributes = if attributes.length > 0
      '\n' + attributes + aIndent
    else
      ' '
    """
    #{indent}<#{@name}#{attributes}/>\n
    """

module.exports.EmptyElement = EmptyElement
{'fraction_non_alphanumeric': 0.17901568415359653, 'fraction_numerical': 0.003244997295835587, 'mean_word_length': 2.274336283185841, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 20, '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': '6056435', 'n_tokens_mistral': 631, 'n_tokens_neox': 632, 'n_words': 158}