<commit_before>'use strict';

var cheerio = require('cheerio');
var forEach = require('lodash.foreach');
var format = require('util').format;
var path = require('path');

module.exports = function (source) {
  this.cacheable();

  var warnings = [];
  var key = this.query.substring(1) || 'htmlTest';

  var filename = path.relative(this.options.context, this.resourcePath);
  var $ = cheerio(source);

  var config = this.options[key] || {};

  forEach(config, function (assertion, test) {
    var nodes = $.find(test);

    forEach(nodes, function (node) {
      var $node = cheerio(node);
      if (!$node.is(assertion)) {
        warnings.push(format('%s from %s failed the \'%s\' assertion.', $node.toString(), filename, assertion));
      }
    });
  });

  if (warnings.length) {
    this.emitWarning(warnings.join('\n'));
  }<commit_msg>Always wrap a parent div around the source being tested.<commit_after>'use strict';

var cheerio = require('cheerio');
var forEach = require('lodash.foreach');
var format = require('util').format;
var path = require('path');

module.exports = function (source) {
  this.cacheable();

  var warnings = [];
  var key = this.query.substring(1) || 'htmlTest';

  var filename = path.relative(this.options.context, this.resourcePath);
  var $ = cheerio('<div>' + source + '</div>');

  var config = this.options[key] || {};

  forEach(config, function (assertion, test) {
    var nodes = $.find(test);

    forEach(nodes, function (node) {
      var $node = cheerio(node);
      if (!$node.is(assertion)) {
        warnings.push(format('%s from %s failed the \'%s\' assertion.', $node.toString(), filename, assertion));
      }
    });
  });

  if (warnings.length) {
    this.emitWarning(warnings.join('\n'));
  }
{'fraction_non_alphanumeric': 0.18129988597491448, 'fraction_numerical': 0.0011402508551881414, 'mean_word_length': 3.717741935483871, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1604614', 'n_tokens_mistral': 566, 'n_tokens_neox': 545, 'n_words': 133}