<commit_before>module ElementsHelper
  def render_elements(elements)
    elements.each do |element|
      partial = find_element_partial(element) ? element.tag : "element"
      concat(render(:partial => "elements/#{partial}", :locals => { :element => element }))
    end
    nil
  end
  
  def render_footnote(element)
    @footnote_count ||= 0
    @footnote_count += 1
    footnote = Nokogiri::HTML(element.content)
    footnote.content = "<a name='footnote_#{@footnote_count}'></a><sup>#{@footnote_count}</sup> #{footnote.to_html}<br />".html_safe
  end
  
  private

  def find_element_partial(element)
    @partials ||= {}
    return @partials[element.tag] unless @partials[element.tag].nil?
    partial = Rails.root + "app/views/elements/_#{element.tag}.html.erb"
    @partials[element.tag] = File.exist?(partial)
  end
end<commit_msg>Improve footnote formatting<commit_after>module ElementsHelper
  def render_elements(elements)
    elements.each do |element|
      partial = find_element_partial(element) ? element.tag : "element"
      concat(render(:partial => "elements/#{partial}", :locals => { :element => element }))
    end
    nil
  end
  
  def render_footnote(element)
    @footnote_count ||= 0
    @footnote_count += 1
    footnote = Nokogiri::HTML(element.content)
    # TODO: Work out a better way to style the whole footnote container
    content_tag("span", :class => "footnote_container") do
      "<a name='footnote_#{@footnote_count}'></a><sup>#{@footnote_count}</sup> #{footnote.to_html}<br />".html_safe
    end
  end
  
  private

  def find_element_partial(element)
    @partials ||= {}
    return @partials[element.tag] unless @partials[element.tag].nil?
    partial = Rails.root + "app/views/elements/_#{element.tag}.html.erb"
    @partials[element.tag] = File.exist?(partial)
  end
end
{'fraction_non_alphanumeric': 0.14521452145214522, 'fraction_numerical': 0.0022002200220022, 'mean_word_length': 4.066852367688022, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 20, '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': '5900044', 'n_tokens_mistral': 589, 'n_tokens_neox': 594, 'n_words': 113}