<commit_before>require "./parser"

# :nodoc:
class Crustache::IndentIO < IO

  def initialize(@indent : String, @io : IO)
    @indent_flag = 0
    @eol_flag = true
  end

  def indent_flag_on
    @indent_flag -= 1
  end

  def indent_flag_off
    @indent_flag += 1
  end

  def read(s : Slice(UInt8))
    raise "Unsupported"
  end

  def write(s) : Nil
    start = 0
    size = s.size
    i = 0
    while i < size
      if @eol_flag
        @io.write s[start, i - start]
        @io << @indent
        @eol_flag = false
        start = i
      end

      if s[i] == Parser::NEWLINE_N && @indent_flag == 0
        @eol_flag = true
      end

      i += 1
    end

    @io.write s[start, i - start]
  end
end<commit_msg>Fix return type restriction since Crystal 0.35.0<commit_after>require "./parser"

# :nodoc:
class Crustache::IndentIO < IO
  def initialize(@indent : String, @io : IO)
    @indent_flag = 0
    @eol_flag = true
  end

  def indent_flag_on
    @indent_flag -= 1
  end

  def indent_flag_off
    @indent_flag += 1
  end

  def read(s : Slice(UInt8))
    raise "Unsupported"
  end

  {% begin %}
    def write(s) : {% if compare_versions(Crystal::VERSION, "0.35.0") >= 0 %}Int64{% else %}Nil{% end %}
      start = 0
      size = s.size
      i = 0
      while i < size
        if @eol_flag
          @io.write s[start, i - start]
          @io << @indent
          @eol_flag = false
          start = i
        end

        if s[i] == Parser::NEWLINE_N && @indent_flag == 0
          @eol_flag = true
        end

        i += 1
      end

      @io.write s[start, i - start]
    end
  {% end %}
end
{'fraction_non_alphanumeric': 0.11957868649318464, 'fraction_numerical': 0.016728624535315983, 'mean_word_length': 1.8736654804270463, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 4, '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': '1045656', 'n_tokens_mistral': 625, 'n_tokens_neox': 579, 'n_words': 162}