<commit_before># encoding: utf-8

class CSSLintFilter < Nanoc::Filter
  requires 'execcsslint'

  identifier :csslint
  type :text

  def run(content, params={})
    messages = CSSLint.run(content).error_messages

    "csslint: #{item.identifier.chop}.#{item[:extension]}", messages unless messages.empty?

    # Don't raise an exception by default since CSS will generally work.
    if params[:strict]
        raise RuntimeError, "csslint: fatal error" unless result.valid?
    end
<commit_msg>Restructured to allow for the optional exception handling<commit_after># encoding: utf-8

class CSSLintFilter < Nanoc::Filter
  requires 'execcsslint'

  identifier :csslint
  type :text

  def run(content, params={})
    result = CSSLint.run(content)
    
    puts "csslint: #{item.identifier.chop}.#{item[:extension]}", result.error_messages unless result.error_messages.empty?
    
    # Don't raise an exception by default since CSS will generally work.
    if params[:strict]
        raise RuntimeError, "csslint: fatal error\n#{result.error_messages.select{|m| m =~ /error/}}" unless result.valid?
    end

{'fraction_non_alphanumeric': 0.1111111111111111, 'fraction_numerical': 0.0018066847335140017, 'mean_word_length': 4.08256880733945, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6501998', 'n_tokens_mistral': 337, 'n_tokens_neox': 327, 'n_words': 96}