<commit_before>CI.terminal =
  ansiToHtmlConverter: (defaultColor) ->
    trailing_raw = ""
    trailing_out = ""
    style =
      color: defaultColor
      italic: false
      bold: false

      reset: () ->
        @color = defaultColor
        @italic = false
        @bold = false

      add: (n) ->
        switch parseInt(n)
          when 0 then @reset()
          when 1 then @bold = true
          when 3 then @italic = true
          when 22 then @bold = false
          when 23 then @italic = false
          when 30 then @color = "white" ## actually black, but we use a black background
          when 31 then @color = "red"
          when 32 then @color = "green"
          when 33 then @color = "yellow"
          when 34 then @color = "blue"
          when 35 then @color = "magenta"
          when 36 then @color = "cyan"
          when 37 then @color = "white"
          when 39 then @color = defaultColor

      classes: () ->
        classes = []
        if @bold and not @color.match(/^br/)
          classes.push("br#{@color}")
        else if @color != defaultColor
          classes.push("#{@color}")
        if @italic
          classes.push("italic")

        classes


      applyTo: (content) ->
        if content
          classes = @classes()
          if classes.length
            "<span class='#{classes.join(' ')}'>#{content}</span>"
          else
            content
        else
          ""

    wrapDefaultColor: (content) -><commit_msg>add way to get and set state of the terminal converter<commit_after>CI.terminal =
  ansiToHtmlConverter: (defaultColor, state={}) ->
    default_state =
      trailing_raw: ""
      trailing_out: ""
      color: defaultColor
      italic: false
      bold: false

    initial_state = _.extend(default_state, state)

    trailing_raw = initial_state.trailing_raw
    trailing_out = initial_state.trailing_out

    style =
      color: initial_state.color
      italic: initial_state.italic
      bold: initial_state.bold

      reset: () ->
        @color = defaultColor
        @italic = false
        @bold = false

      add: (n) ->
        switch parseInt(n)
          when 0 then @reset()
          when 1 then @bold = true
          when 3 then @italic = true
          when 22 then @bold = false
          when 23 then @italic = false
          when 30 then @color = "white" ## actually black, but we use a black background
          when 31 then @color = "red"
          when 32 then @color = "green"
          when 33 then @color = "yellow"
          when 34 then @color = "blue"
          when 35 then @color = "magenta"
          when 36 then @color = "cyan"
          when 37 then @color = "white"
          when 39 then @color = defaultColor

      classes: () ->
        classes = []
        if @bold and not @color.match(/^br/)
          classes.push("br#{@color}")
        else if @color != defaultColor
          classes.push("#{@color}")
        if @italic
          classes.push("italic")

        classes


      applyTo: (content) ->
        if content
          classes = @classes()
          if classes.length
            "<span class='#{classes.join(' ')}'>#{content}</span>"
          else
            content
        else
          ""
      currentState: () ->
        color: @color
        italic: @italic
        bold: @bold


    currentState: () ->
      _.extend
        trailing_raw: trailing_raw
        trailing_out: trailing_out
      , style.currentState()


    wrapDefaultColor: (content) ->
{'fraction_non_alphanumeric': 0.10756062767475036, 'fraction_numerical': 0.014265335235378032, 'mean_word_length': 1.6783804430863254, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, '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': '6851637', 'n_tokens_mistral': 1027, 'n_tokens_neox': 975, 'n_words': 305}