<commit_before>/*
 * grunt-link-html
 * https://github.com/pythonandchips/grunt-link-html
 *
 * Copyright (c) 2013 <NAME>
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  grunt.registerMultiTask('link_html', 'link css and javascipt in html file', function() {

    var options = this.options({
      expand: true,
      cwd: '.'
    });

    //TODO: test this method away from the rest of the code. not sure how to do that yet.
    var includes = function(template, path, options){
      var cssFiles = grunt.file.expand(options, path);
      var cssIncludes = cssFiles.map( function(file) {
        return grunt.template.process(template, {data: {file: file}});
      });
      cssIncludes.unshift('');
      cssIncludes = cssIncludes.join('\n') + '\n';
      return cssIncludes;
    };

    //TODO: test this method away from the rest of the code. not sure how to do that yet.
    var processIncludes = function(filepath, content, fileType, files) {
      var begin = content.html.match(new RegExp('<!--\\s*begin:' + fileType + '\\s*-->'));
      var skip = false;
      if(begin){
      var end = content.html.match(new RegExp('<!--\\s*end:' + fileType + '\\s*-->')).index;
      var startReplace = begin.index + begin[0].length;
      content.html = content.html.substring(0, startReplace) + files + content.html.substring(end, content.html.length);
      } else {
        skip = true;
        grunt.log.ok('Skipping ' + fileType  + ' for '+filepath);
      }
      return skip;
    };

    var cssIncludes = includes('<link rel="stylesheet" type="text/css" href="<%= file %>">', this.data.cssFiles, options);
    var jsIncludes = includes('<script src="<%= file %>"></script>', this.data.jsFiles, options);
    var targetFiles = grunt.file.expand(options, this.data.targetHtml);
<commit_msg>Update link_html.js<commit_after>/*
 * grunt-link-html
 * https://github.com/pythonandchips/grunt-link-html
 *
 * Copyright (c) 2013 <NAME>
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  grunt.registerMultiTask('link_html', 'link css and javascipt in html file', function() {

    var options = this.options({
      expand: true,
      cwd: '.'
    });

    //TODO: test this method away from the rest of the code. not sure how to do that yet.
    var includes = function(template, path, options){
      var cssFiles = grunt.file.expand(options, path);
      var cssIncludes = cssFiles.map( function(file) {
        return grunt.template.process(template, {data: {file: file}});
      });
      cssIncludes.unshift('');
      cssIncludes = cssIncludes.join('\n') + '\n';
      return cssIncludes;
    };

    //TODO: test this method away from the rest of the code. not sure how to do that yet.
    var processIncludes = function(filepath, content, fileType, files) {
      var begin = content.html.match(new RegExp('<!--\\s*begin:' + fileType + '\\s*-->'));
      var skip = false;
      if(begin){
      var end = content.html.match(new RegExp('<!--\\s*end:' + fileType + '\\s*-->')).index;
      var startReplace = begin.index + begin[0].length;
      content.html = content.html.substring(0, startReplace) + files + content.html.substring(end, content.html.length);
      } else {
        skip = true;
        grunt.log.ok('Skipping ' + fileType  + ' for '+filepath);
      }
      return skip;
    };

    var cssIncludes = includes('<link rel="stylesheet" type="text/css" href="<%= file %>" />', this.data.cssFiles, options);
    var jsIncludes = includes('<script src="<%= file %>"></script>', this.data.jsFiles, options);
    var targetFiles = grunt.file.expand(options, this.data.targetHtml);

{'fraction_non_alphanumeric': 0.16106290672451193, 'fraction_numerical': 0.0032537960954446853, 'mean_word_length': 2.9795037756202807, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 2, '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': '4849235', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1148, 'n_words': 307}