<commit_before># Here is my attempt at a custom Liquid Tag
# It's supposed to be used like this {% tag_toggler datafile column %}
# Where you already have a Jekyll data available in `site.data.datafile`
# and a column named `column` in which you have a value or an array of comma-separated values

# lessons learned while getting args:
      # either you're not getting any help OR I missed the standard way of doing this.

# lessons learned while getting data:
      # transform variable name in data: not `evaluate`, not `find_variable`...
      # perhaps c.environments.first['a_tag_on_your_FrontMatter']

# TODO : add options, HTML options, and ability to sort by frequency OR alphabetical order

module Jekyll
  class RenderTagToggler < Liquid::Tag

    def initialize(tag_name, argstring, tokens)
      super

      # get args
      args = argstring.gsub(%Q['"], '').split(/[, ]/).map(&:strip)
      @data = args.first
      @method = args.last

      # options, if I get t ounderstand how I can do that later
      opts = {}
      @tag = opts[:tag] || 'a'
      @join = opts[:join] || ' '
      @class = opts[:class] || 'tag'
      @id = opts[:id] || 'tags'

      # now wait until it evaluates

    end

    def render(context)
      # get data from
      data =    context.environments.first['site']['data'][@data]
      raw = data.map{|d| d[@method] }

      # get the tags
      @tags = raw.map{|r| r.to_s.split(',') }.flatten.map(&:strip).uniq.reject{|x| x.size == 0}.sort

      # outputs HTML
      cloud = @tags.map{|t| %Q[<#{@tag} class="#{@class}">#{t}</#{@tag}>] }.join(@join)
      %Q[<div id="#{@id}">#{cloud}</div>]

    end
  end
end

Liquid::Template.register_tag('tag_toggler', Jekyll::RenderTagToggler)<commit_msg>Jekyll 3 compatibility and posts compatibility.<commit_after># Here is my attempt at a custom Liquid Tag
# It's supposed to be used like this {% tag_toggler datafile column %}
# Where you already have a Jekyll data available in `site.data.datafile`
# and a column named `column` in which you have a value or an array of comma-separated values

# lessons learned while getting args:
      # either you're not getting any help OR I missed the standard way of doing this.

# lessons learned while getting data:
      # transform variable name in data: not `evaluate`, not `find_variable`...
      # perhaps c.environments.first['a_tag_on_your_FrontMatter']

# TODO : add options, HTML options, and ability to sort by frequency OR alphabetical order

module Jekyll
  class RenderTagToggler < Liquid::Tag

    def initialize(tag_name, argstring, tokens)
      super

      # get args
      args = argstring.gsub(%Q['"], '').split(/[, ]/).map(&:strip)
      @data = args.first
      @method = args.last

      # options, if I get t ounderstand how I can do that later
      opts = {}
      @tag = opts[:tag] || 'a'
      @join = opts[:join] || ' '
      @class = opts[:class] || 'tag'
      @id = opts[:id] || 'tags'

      # now wait until it evaluates

    end

    def render(context)
      # get data from
      data =    context.environments.first['site']['data'][@data]
      data =    context.environments.first['site']['posts'] if !data

      raw =     data.first.respond_to?(:keys) && data.first.keys.size == 1 ?
          data.map{|d| d.values.first[@method] } : # an item has a name and attributes
          data.map{|d| d[@method] }                # an item is a list of attributes

      # get the tags
      @tags = raw.map{|r| r.to_s.split(',') }.flatten.map(&:strip).uniq.reject{|x| x.size == 0}.sort {|a,b| a.downcase <=> b.downcase }

      # outputs HTML
      cloud = @tags.map{|t| %Q[<#{@tag} class="#{@class}">#{t}</#{@tag}>] }.join(@join)
      %Q[<div id="#{@id}">#{cloud}</div>]

    end
  end
end

Liquid::Template.register_tag('tag_toggler', Jekyll::RenderTagToggler)
{'fraction_non_alphanumeric': 0.14420062695924765, 'fraction_numerical': 0.0010449320794148381, 'mean_word_length': 2.9968684759916493, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 12, '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': '4283492', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1208, 'n_words': 390}