<commit_before>module PictureTag
  module OutputFormats
    # Represents a <picture> tag, enclosing at least 2 <source> tags and an
    # <img> tag.
    class Picture
      include Basics
      def srcsets
        sets = []

        @instructions.preset['formats'].each do |format|
          # Source images are defined by their media queries:
          @instructions.source_images.each_key do |media|
            sets << build_srcset(media, format)
          end
        end

        # Media queries are given from most to least restrictive, but the markup
        # requires them the other way around:
        sets.reverse
      end

      def build_picture
        DoubleTag.new(
          'picture',
          # attributes: @instructions.html_attributes['picture'],
          content: build_sources << build_base_img
        )
      end

      def build_sources
        srcsets.collect { |s| build_source(s) }
      end

      def build_source(srcset)
        source = SingleTag.new('source')
                               # attributes: @instructions.html_attributes['source'])

        # Sizes will be the same for all sources. There's some redundant markup
        # here, but I don't think it's worth the effort to prevent.
        source.sizes = srcset.sizes if srcset.sizes

        # The srcset has an associated media query, which might be nil. Don't
        # apply it if that's the case:
        source.media = srcset.media if srcset.media

        source.type = srcset.mime_type

        source.srcset = srcset.to_s
        source
      end<commit_msg>Updated picture output to use config<commit_after>module PictureTag
  module OutputFormats
    # Represents a <picture> tag, enclosing at least 2 <source> tags and an
    # <img> tag.
    class Picture
      include Basics
      def srcsets
        sets = []

        PictureTag.config.preset['formats'].each do |format|
          # Source images are defined by their media queries:
          PictureTag.config.source_images.each_key do |media|
            sets << build_srcset(media, format)
          end
        end

        # Media queries are given from most to least restrictive, but the markup
        # requires them the other way around:
        sets.reverse
      end

      def build_picture
        DoubleTag.new(
          'picture',
          # attributes: PictureTag.config.html_attributes['picture'],
          content: build_sources << build_base_img
        )
      end

      def build_sources
        srcsets.collect { |s| build_source(s) }
      end

      def build_source(srcset)
        source = SingleTag.new('source')
        # attributes: PictureTag.config.html_attributes['source'])

        # Sizes will be the same for all sources. There's some redundant markup
        # here, but I don't think it's worth the effort to prevent.
        source.sizes = srcset.sizes if srcset.sizes

        # The srcset has an associated media query, which might be nil. Don't
        # apply it if that's the case:
        source.media = srcset.media if srcset.media

        source.type = srcset.mime_type

        source.srcset = srcset.to_s
        source
      end
{'fraction_non_alphanumeric': 0.07174603174603175, 'fraction_numerical': 0.0006349206349206349, 'mean_word_length': 2.0741463414634147, 'pattern_counts': {'":': 0, '<': 17, '<?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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5004843', 'n_tokens_mistral': 873, 'n_tokens_neox': 828, 'n_words': 286}