<commit_before>'use strict';

var _    = require('lodash');
var path = require('path');

var packageJSON = require('../package');
var utility     = require('./utility');

var filterCB,
    languages = { pattern: path.join('src', 'languages', '*.js') },
    header    = utility.regex.header;

function buildLanguages() {
  var input  = languages,
      output = path.join(dir.build, 'lib', 'languages'),

      replaceArgs = utility.replace(header, ''),
      template    = 'module.exports = <%= content %>;';

  return {
    logjs: { task: ['log', 'Building language files.'] },
    readjs: { requires: 'logjs', task: ['glob', input] },
    filterjs: { requires: 'readjs', task: ['filter', filterCB] },
    replacejs: { requires: 'filterjs', task: ['replace', replaceArgs] },
    templatejs: { requires: 'replacejs', task: ['template', template] },
    writejslog: {
      requires: 'templatejs',
      task: ['log', 'Writing language files.']
    },
    writejs: { requires: 'writejslog', task: ['dest', output] }
  };
}

function buildCore() {
  var input    = path.join(dir.root, 'src', 'highlight.js'),
      output   = path.join(dir.build, 'lib'),

      replaceArgs = utility.replace(header, ''),
      template    = 'var Highlight = <%= content %>;' +
                    '\nmodule.exports = Highlight;';

  return {
    logCore: { task: ['log', 'Building core file.'] },
    readCore: { requires: 'logCore',  task: ['read', input] },
    replaceCore: { requires: 'readCore', task: ['replace', replaceArgs] },
    templateCore: {
      requires: 'replaceCore',
      task: ['template', template]
    },
    writeCoreLog: {
      requires: 'templateCore',
      task: ['log', 'Writing core file.']
    },
    writeCore: { requires: 'writeCoreLog', task: ['dest', output] }
  };
}

function buildIndex() {
  var input  = languages,
      output = path.join(dir.build, 'lib', 'index.js'),

      template =
    [ 'var Highlight = require(\'./highlight\');'
    , 'var hljs      = new Highlight();\n'
    , '<% _.each(names, function(name) { %>' +
      'hljs.registerLanguage(\'<%= name %>\', ' +
      'require(\'./languages/<%= name %>\'));'
    , '<% }); %>'
    , 'module.exports = hljs;'
    ];

  return {
    logIndex: { task: ['log', 'Building index file.'] },
    readIndex: { requires: 'logIndex', task: ['glob', input] },
    filterIndex: { requires: 'readIndex', task: ['filter', filterCB] },
    reorderIndex: { requires: 'filterIndex', task: 'reorderDeps' },
    templateIndex: {<commit_msg>Only copy over core of highlight.js<commit_after>'use strict';

var _    = require('lodash');
var path = require('path');

var packageJSON = require('../package');
var utility     = require('./utility');

var filterCB,
    languages = { pattern: path.join('src', 'languages', '*.js') },
    header    = utility.regex.header;

function buildLanguages() {
  var input  = languages,
      output = path.join(dir.build, 'lib', 'languages'),

      replaceArgs = utility.replace(header, ''),
      template    = 'module.exports = <%= content %>;';

  return {
    logjs: { task: ['log', 'Building language files.'] },
    readjs: { requires: 'logjs', task: ['glob', input] },
    filterjs: { requires: 'readjs', task: ['filter', filterCB] },
    replacejs: { requires: 'filterjs', task: ['replace', replaceArgs] },
    templatejs: { requires: 'replacejs', task: ['template', template] },
    writejslog: {
      requires: 'templatejs',
      task: ['log', 'Writing language files.']
    },
    writejs: { requires: 'writejslog', task: ['dest', output] }
  };
}

function buildCore() {
  var input    = path.join(dir.root, 'src', 'highlight.js'),
      output   = path.join(dir.build, 'lib');

  return {
    logCore: { task: ['log', 'Building core file.'] },
    readCore: { requires: 'logCore',  task: ['read', input] },
    writeCoreLog: {
      requires: 'readCore',
      task: ['log', 'Writing core file.']
    },
    writeCore: { requires: 'writeCoreLog', task: ['dest', output] }
  };
}

function buildIndex() {
  var input  = languages,
      output = path.join(dir.build, 'lib', 'index.js'),

      template =
    [ 'var Highlight = require(\'./highlight\');'
    , 'var hljs      = new Highlight();\n'
    , '<% _.each(names, function(name) { %>' +
      'hljs.registerLanguage(\'<%= name %>\', ' +
      'require(\'./languages/<%= name %>\'));'
    , '<% }); %>'
    , 'module.exports = hljs;'
    ];

  return {
    logIndex: { task: ['log', 'Building index file.'] },
    readIndex: { requires: 'logIndex', task: ['glob', input] },
    filterIndex: { requires: 'readIndex', task: ['filter', filterCB] },
    reorderIndex: { requires: 'filterIndex', task: 'reorderDeps' },
    templateIndex: {
{'fraction_non_alphanumeric': 0.200254831174347, 'fraction_numerical': 0.0, 'mean_word_length': 3.1243432574430825, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '1820112', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1493, 'n_words': 361}