<commit_before>
/**
 * juice
 * Copyright(c) 2011 LearnBoost <<EMAIL>>
 * MIT Licensed
 */

module.exports = exports = juice;

/**
 * Module dependencies.
 */

var soupselect = require('soupselect')
  , utils = require('./utils')
  , Selector = require('./selector')
  , Property = require('./property')

/**
 * Export Selector.
 */

exports.Selector = Selector;

/**
 * Export Property.
 */

exports.Property = Property;

/**
 * Export utils.
 */

exports.utils = require('./utils');

/**
 * Inlines the CSS specified by `css` into the `html`
 *
 * @param {String} html
 * @param {String} css
 * @api public
 */

function juice (html, css, options) {
  var rules = utils.parseCSS(css)
    , dom = utils.parseHTML(html)
    , editedElements = []
    , topmost = new Selector('<style attribute>', [1, 0, 0, 0])
    , options = options || {}

  function select (sel) {
    return soupselect.select(dom, sel);
  }

  rules.forEach(function (rule) {
    var sel = rule[0]
      , style = rule[1]
      , matches = select(sel)
      , selector

    console.log('\ngot selector "%s" - matches: %s ', sel, matches.length);
    matches.forEach(function (el) {
      // we initialize the Selector lazily to avoid needless parsing
      if (!selector) {
        selector = new Selector(sel)
        console.log(
            'selector "%s" has specificity "%s"'
          , sel
          , JSON.stringify(selector.specificity())
        );
      }

      if (!el.styleProps) {
        el.styleProps = {}

        // if the element has inline styles, fake selector with topmost specificity
        if (el.attribs && el.attribs.style) {
          console.log('element has inline style - caching properties');<commit_msg>Cleaned up logging<commit_after>
/**
 * juice
 * Copyright(c) 2011 LearnBoost <<EMAIL>>
 * MIT Licensed
 */

module.exports = exports = juice;

/**
 * Module dependencies.
 */

var soupselect = require('soupselect')
  , utils = require('./utils')
  , Selector = require('./selector')
  , Property = require('./property')

/**
 * Export Selector.
 */

exports.Selector = Selector;

/**
 * Export Property.
 */

exports.Property = Property;

/**
 * Export utils.
 */

exports.utils = require('./utils');

/**
 * Inlines the CSS specified by `css` into the `html`
 *
 * @param {String} html
 * @param {String} css
 * @api public
 */

function juice (html, css, options) {
  var rules = utils.parseCSS(css)
    , dom = utils.parseHTML(html)
    , editedElements = []
    , topmost = new Selector('<style attribute>', [1, 0, 0, 0])
    , options = options || {}

  function select (sel) {
    return soupselect.select(dom, sel);
  }

  rules.forEach(function (rule) {
    var sel = rule[0]
      , style = rule[1]
      , matches = select(sel)
      , selector

    if (options.log)
      console.log('\ngot selector "%s" - matches: %s ', sel, matches.length);

    matches.forEach(function (el) {
      // we initialize the Selector lazily to avoid needless parsing
      if (!selector) {
        selector = new Selector(sel)

        if (options.log)
          console.log(
              'selector "%s" has specificity "%s"'
            , sel
            , JSON.stringify(selector.specificity())
          );
      }

      if (!el.styleProps) {
        el.styleProps = {}

        // if the element has inline styles, fake selector with topmost specificity
        if (el.attribs && el.attribs.style) {
          console.log('element has inline style - caching properties');
{'fraction_non_alphanumeric': 0.1488933601609658, 'fraction_numerical': 0.005748778384593274, 'mean_word_length': 2.504531722054381, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2675011', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1049, 'n_words': 289}