<commit_before>module Kramdown
  module Converter

    # Converts kramdown element tree to subtitle text.
    class Subtitle < Base

      # Instantiate a Subtitle converter
      # @param [Kramdown::Element] root
      # @param [Hash{Symbol => Object}] options
      def initialize(root, options)
        super
        @output = '' # collector for output string
        @current_record_id = nil
        @include_record_ids = options[:include_record_ids]
      end

      # Extracts subtitle from tree
      # @param [Kramdown::Element] el
      # @return [String] the subtitle text
      def convert(el)
        case el.type
        when :blank
          # nothing to do
        when :em
          if el.has_class?('pn')
            # replace space after paragraph numbers with 4 spaces. Done in post processing
            @output << "<<replace space after with 4 spaces>>"
          end
        when :entity
          # Decode whitelisted entities
          @output << Repositext::Utils::EntityEncoder.decode(el.options[:original])
        when :gap_mark
          # export gap_marks
          @output << gap_mark_output
        when :header
          # put opening part of header wrapper. Post processing will close it
          case el.options[:level]
          when 1
            # render as H1
            @output << "\n[|# "
          when 2
            # render as H2
            @output << "\n[|## "<commit_msg>Handle .line_break IAL when exporting subtitle<commit_after>module Kramdown
  module Converter

    # Converts kramdown element tree to subtitle text.
    class Subtitle < Base

      # Instantiate a Subtitle converter
      # @param [Kramdown::Element] root
      # @param [Hash{Symbol => Object}] options
      def initialize(root, options)
        super
        @output = '' # collector for output string
        @current_record_id = nil
        @include_record_ids = options[:include_record_ids]
      end

      # Extracts subtitle from tree
      # @param [Kramdown::Element] el
      # @return [String] the subtitle text
      def convert(el)
        case el.type
        when :blank
          # nothing to do
        when :em
          if el.has_class?('pn')
            # replace space after paragraph numbers with 4 spaces. Done in post processing
            @output << "<<replace space after with 4 spaces>>"
          elsif el.has_class?('line_break')
            # line_break, ignore self and children
            el.children = []
          end
        when :entity
          # Decode whitelisted entities
          @output << Repositext::Utils::EntityEncoder.decode(el.options[:original])
        when :gap_mark
          # export gap_marks
          @output << gap_mark_output
        when :header
          # put opening part of header wrapper. Post processing will close it
          case el.options[:level]
          when 1
            # render as H1
            @output << "\n[|# "
          when 2
            # render as H2
            @output << "\n[|## "
{'fraction_non_alphanumeric': 0.08369456485495165, 'fraction_numerical': 0.0040013337779259755, 'mean_word_length': 1.8901734104046244, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 9, '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': '3499000', 'n_tokens_mistral': 810, 'n_tokens_neox': 781, 'n_words': 265}