<commit_before># Frozen-string-literal: true
# Copyright: 2012 - 2017 - MIT License
# Encoding: utf-8

require "fastimage"
require_relative "html"
require "liquid/tag/parser"
require "active_support/hash_with_indifferent_access"
require "active_support/core_ext/hash/indifferent_access"
require "active_support/core_ext/hash/deep_merge"
require_relative "default"
require_relative "proxy"
require "nokogiri"

module Jekyll
  module Assets
    class Tag < Liquid::Tag
      class << self
        public :new
      end

      # --
      attr_reader :name
      attr_reader :tokens
      attr_reader :args
      attr_reader :tag

      # --
      def initialize(tag, args, tokens)
        @tag = tag.to_sym
        @args = Liquid::Tag::Parser.new(args)
        @name = @args[:argv1]
        @tokens = tokens

        super
      end

      # --
      # @return [String]
      # Render the tag, run the proxies, set the defaults.
      # @note Defaults are ran twice just incase the content type
      #   changes, at that point there might be something that
      #   has to change in the new content.
      # --
      def render(context)
        env = context.registers[:site].sprockets

        o_asset = env.find_asset!(@name)
        Default.set(@args, env: env, asset: o_asset)
        asset = Proxy.proxy(o_asset, args: @args, env: env)
        Default.set(@args, env: env, asset: asset)
        env.manifest.compile(asset.filename)

        return env.prefix_url(asset.digest_path) if @args[:path]
        return asset.data_uri if @args[:"data-uri"] || @args[:data_uri]
        return asset.to_s if @args[:source]
        type = asset.content_type

        HTML.build({
          args: @args,
          asset: asset,
          type: type,
          env: env,
        })
      end
    end
  end
end

# --

Liquid::Template.register_tag "asset", Jekyll::Assets::Tag
<commit_msg>Use logical_path to avoid problems.<commit_after># Frozen-string-literal: true
# Copyright: 2012 - 2017 - MIT License
# Encoding: utf-8

require "fastimage"
require_relative "html"
require "liquid/tag/parser"
require "active_support/hash_with_indifferent_access"
require "active_support/core_ext/hash/indifferent_access"
require "active_support/core_ext/hash/deep_merge"
require_relative "default"
require_relative "proxy"
require "nokogiri"

module Jekyll
  module Assets
    class Tag < Liquid::Tag
      class << self
        public :new
      end

      # --
      attr_reader :name
      attr_reader :tokens
      attr_reader :args
      attr_reader :tag

      # --
      def initialize(tag, args, tokens)
        @tag = tag.to_sym
        @args = Liquid::Tag::Parser.new(args)
        @name = @args[:argv1]
        @tokens = tokens

        super
      end

      # --
      # @return [String]
      # Render the tag, run the proxies, set the defaults.
      # @note Defaults are ran twice just incase the content type
      #   changes, at that point there might be something that
      #   has to change in the new content.
      # --
      def render(context)
        env = context.registers[:site].sprockets

        o_asset = env.find_asset!(@name)
        Default.set(@args, env: env, asset: o_asset)
        asset = Proxy.proxy(o_asset, args: @args, env: env)
        Default.set(@args, env: env, asset: asset)
        env.manifest.compile(asset.logical_path)

        return env.prefix_url(asset.digest_path) if @args[:path]
        return asset.data_uri if @args[:"data-uri"] || @args[:data_uri]
        return asset.to_s if @args[:source]
        type = asset.content_type

        HTML.build({
          args: @args,
          asset: asset,
          type: type,
          env: env,
        })
      end
    end
  end
end

# --

Liquid::Template.register_tag "asset", Jekyll::Assets::Tag

{'fraction_non_alphanumeric': 0.10644479661912308, 'fraction_numerical': 0.005282620179609086, 'mean_word_length': 2.3994614003590664, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, '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': '2849512', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1167, 'n_words': 310}