<commit_before>var Plates = function main(undefined) {
  
  var Merge = function Merge() {};

  Merge.prototype = {

    tag: new RegExp(
      [
        '\\s*',
        '<',
        '(/?)', // 1 - is closing
        '([-:\\w]+)', // 2 - name
        '((?:\\s+[-\\w]+(?:', '=', '(?:' +
          '\\w+|' +
          '"[^"]*"|' +
          '\'[^\']*\'))?)*)', // 3 - attributes
        '(/?)', // 4 - is self-closing
        '>'
      ].join('\\s*'),
      'gi'
    ),

    attr: new RegExp(
      '([-\\w]+)=(?:["\']([-\\w\\s]+)["\'])', // '([-\\w]+)=(?:([-\\w]+)|["\']([-\\w\\s]+)["\'])'
      'gi'
    ),

    bind: function bind(html, data, map) {

      while (matchedTag = this.tag.exec(html)) {
        
        //
        // must not be a closing tag, must not be 
        // self-closing, must have attributes.
        //
        if (matchedTag[1] !== '/' && matchedTag[3] !== '' && matchedTag[4] === '') {

          if (!map) {
            
            while (matchedAttr = this.attr.exec(matchedTag[3])) {

              //
              // has an attribute who's value is a match.
              //
              if (matchedAttr[1] === 'id' && data[matchedAttr[2]]) {
                var idx = matchedTag.index + matchedTag[0].length;
                html = html.slice(0, idx) + data[matchedAttr[2]] + html.slice(idx);
              }
            }

          }
          else {

            //
            // if there is a map, the user wants an explicit 
            // data-key to tag-attribute match.
            //
            for (var key in map) {
              if (data[key]) {
                while (matchedAttr = this.attr.exec(matchedTag[3])) {

                  //
                  // has an attribute who's value is a match.
                  //
                  if (matchedAttr[1] === map[key] && data[matchedAttr[2]]) {
                    var idx = matchedTag.index + matchedTag[0].length;
                    html = html.slice(0, idx) + data[matchedAttr[2]] + html.slice(idx);
                  }
                }
              }
            }
          
          }
        }
      }

      return html;
    }
  };

  return ({
    bind: function(html, data, map) {
      var merge = new Merge();
      return merge.bind(html, data, map);
    }
  });

}();

exports && (exports.bind = function() {
  return Plates.bind.apply(this, arguments);
});<commit_msg>[lib] simpler is better<commit_after>;var Plates = function main(undefined) {
  
  var Merge = function Merge() {};

  Merge.prototype = {

    tag: new RegExp(
      [
        '\\s*',
        '<',                    // opening bracket
        '(/?)',                 // 1 - is closing
        '([-:\\w]+)',           // 2 - name of tag
        '((?:\\s+[-\\w]+(?:',   // attribute key/value pairs
        '=', 
        '(?:' +
          '\\w+|' +
          '"[^"]*"|' +
          '\'[^\']*\'))?)*)',   // 3 - attributes
        '(/?)',                 // 4 - self-closing
        '>'                     // closing bracket
      ].join('\\s*'),           // whitespace liberal
      'gi'
    ),

    attr: new RegExp(
      '([-\\w]+)=(?:["\']([-\\w\\s]+)["\'])', // '([-\\w]+)=(?:([-\\w]+)|["\']([-\\w\\s]+)["\'])'
      'gi'
    ),

    bind: function bind(html, data, map) {

      while (matchedTag = this.tag.exec(html)) {
        
        //
        // must not be a closing tag, must not be 
        // self-closing, must have attributes.
        //
        if (matchedTag[1] !== '/' && matchedTag[3] !== '' && matchedTag[4] === '') {

          if (!map) {
            
            while (matchedAttr = this.attr.exec(matchedTag[3])) {

              //
              // has an attribute who's value is a match.
              //
              if (matchedAttr[1] === 'id' && data[matchedAttr[2]]) {
                var idx = matchedTag.index + matchedTag[0].length;
                html = html.slice(0, idx) + data[matchedAttr[2]] + html.slice(idx);
              }
            }

          }
          else {

            //
            // if there is a map, the user wants an explicit 
            // data-key to tag-attribute match.
            //
            for (var key in map) {
              if (data[key]) {
                while (matchedAttr = this.attr.exec(matchedTag[3])) {

                  //
                  // has an attribute who's value is a match.
                  //
                  if (matchedAttr[1] === map[key] && data[matchedAttr[2]]) {
                    var idx = matchedTag.index + matchedTag[0].length;
                    html = html.slice(0, idx) + data[matchedAttr[2]] + html.slice(idx);
                  }
                }
              }
            }
          
          }
        }
      }

      return html;
    }
  };

  return ({
    bind: function(html, data, map) {
      var merge = new Merge();
      return merge.bind(html, data, map);
    }
  });

}();

this.exports && (exports.bind = function() {
  return Plates.bind.apply(this, arguments);
});

{'fraction_non_alphanumeric': 0.19764188649080736, 'fraction_numerical': 0.007593924860111911, 'mean_word_length': 1.1694841785869095, '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': '1720797', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1503, 'n_words': 317}