<commit_before>class Muddle::Parser
  attr_accessor :filters

  # Set up the parser
  #
  # The default filters do the following:
  #
  # CSS Filter adds a style block containing boilerplate CSS attributes to be
  #   inlined.  This is based on Email Boilerplate's 'Inline: YES' portions
  #
  # Premailer passes the email through the Premailer gem, which inlines the CSS
  #   it can, then appends a style block to the body containing the rest (since
  #   some email clients strip out the <head> tag).
  #
  # Style Element adds another style block, but this one is intended to be left
  #   as a style declaration (rather than being inlined).  This is based on 
  #   EMail Boilerplate's 'Inline: NO' portions
  #
  # Attributes adds attributes to HTML elements where helpful, such as table cellpadding
  #   and such.  Based on Email Boilerplate's example element declarations
  #
  # Schema Validation currently just adds the XHTML Strict DTD and outputs to a string,
  #   however it's intended that this will eventually validate against an XSD and emit
  #   warnings about potentially troublesome tags (like <div>)
  #
  def initialize
    @filters = []

    @filters << Muddle::BoilerplateCSSFilter if Muddle.config.insert_boilerplate_css
    @filters << Muddle::PremailerFilter if Muddle.config.parse_with_premailer
    @filters << Muddle::BoilerplateStyleElementFilter if Muddle.config.insert_boilerplate_styles
    @filters << Muddle::BoilerplateAttributesFilter if Muddle.config.insert_boilerplate_attributes
    @filters << Muddle::SchemaValidationFilter if Muddle.config.validate_html
  end

  # Parse an email body
  #
  # body_string is the email body to be parsed in string form
  #
  # Returns the parsed body string
  #
  def parse(body_string)
    filters.inject(body_string) {|filtered_string, filter| filter.filter(filtered_string)}
  end
end<commit_msg>Make parser use new classes.<commit_after>class Muddle::Parser
  attr_accessor :filters

  # Set up the parser
  #
  # The default filters do the following:
  #
  # CSS  adds a style block containing boilerplate CSS attributes to be
  #   inlined.  This is based on Email Boilerplate's 'Inline: YES' portions
  #
  # Premailer passes the email through the Premailer gem, which inlines the CSS
  #   it can, then appends a style block to the body containing the rest (since
  #   some email clients strip out the <head> tag).
  #
  # Style Element adds another style block, but this one is intended to be left
  #   as a style declaration (rather than being inlined).  This is based on 
  #   EMail Boilerplate's 'Inline: NO' portions
  #
  # Attributes adds attributes to HTML elements where helpful, such as table cellpadding
  #   and such.  Based on Email Boilerplate's example element declarations
  #
  # Schema Validation currently just adds the XHTML Strict DTD and outputs to a string,
  #   however it's intended that this will eventually validate against an XSD and emit
  #   warnings about potentially troublesome tags (like <div>)
  #
  def initialize
    @filters = []

    @filters << Muddle::Filter::BoilerplateCSS          if Muddle.config.insert_boilerplate_css
    @filters << Muddle::Filter::Premailer               if Muddle.config.parse_with_premailer
    @filters << Muddle::Filter::BoilerplateStyleElement if Muddle.config.insert_boilerplate_styles
    @filters << Muddle::Filter::BoilerplateAttributes   if Muddle.config.insert_boilerplate_attributes
    @filters << Muddle::Filter::SchemaValidation        if Muddle.config.validate_html
  end

  # Parse an email body
  #
  # body_string is the email body to be parsed in string form
  #
  # Returns the parsed body string
  #
  def parse(body_string)
    filters.inject(body_string) {|filtered_string, filter| filter.filter(filtered_string)}
  end
end
{'fraction_non_alphanumeric': 0.06386333771353482, 'fraction_numerical': 0.0, 'mean_word_length': 3.8299492385786804, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 7, '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': '5354915', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1052, 'n_words': 418}