<commit_before>/*
* index.js
* Copyright (C) 2016 dhilipsiva <<EMAIL>>
*
* Distributed under terms of the MIT license.
*/
(function(){
  'use strict';

  var sass = require('node-sass'),
    pug = require('pug'),
    juice = require('juice'),
    cheerio = require('cheerio'),
    Inky = require('inky').Inky,
    minify = require('html-minifier').minify,
    styles, html, inlinedHtml, $, result, css, inky, options, minifiedHtml;

  options = {};

  // Render SCSS to CSS
  styles = sass.renderSync({
    file: 'source/scss/main.scss',
    outputStyle: 'compressed',
  });
  css = styles.css.toString();

  // Render PUG to HTML
  html = pug.renderFile('source/pug/first.pug');

  // Apply Inky on Previous HTML
  $ = cheerio.load(html);
  inky = new Inky();
  html = inky.releaseTheKraken($);

  // Apply the Styles Inline
  inlinedHtml = juice(html, {extraCss: css});

  // Add Additional attributes to HTML
  $ = cheerio.load(inlinedHtml);
  $('table').attr("border", "0");
  $('table').attr("cellpadding", "0");
  $('table').attr("cellspacing", "0");
  $('a').attr("target", "_blank");

  // Save the File
  minifiedHtml = minify($.html(), {
    minifyCSS: true,
    collapseWhitespace: true
  });
  console.log(minifiedHtml);
})();<commit_msg>Read from & Write to files<commit_after>/*
* index.js
* Copyright (C) 2016 dhilipsiva <<EMAIL>>
*
* Distributed under terms of the MIT license.
*/
(function(){
  'use strict';

  var sass = require('node-sass'),
    pug = require('pug'),
    fs = require('fs'),
    juice = require('juice'),
    cheerio = require('cheerio'),
    Inky = require('inky').Inky,
    minify = require('html-minifier').minify,
    sourceDir = "source/",
    distDir = "dist/",
    scssDir = sourceDir + "scss/",
    scssMain = scssDir + "main.scss",
    pugDir = sourceDir + "pug/",
    privateDir = pugDir + "private/",
    styles, html, inlinedHtml, $, result, css, inky, minifiedHtml, files, file,
    i, len, srcPath, targetPath;


  // Render SCSS to CSS
  styles = sass.renderSync({
    file: scssMain,
    outputStyle: 'compressed',
  });
  css = styles.css.toString();

  // List files
  files = fs.readdirSync(privateDir);
  for (i = 0, len = files.length; i < len; i++) {
    file = files[i];
    if (!file.endsWith(".pug")) {
      continue;
    }
    srcPath = privateDir + file;
    targetPath = distDir + file + ".html";
    // Render PUG to HTML
    html = pug.renderFile(srcPath);

    // Apply Inky on Previous HTML
    $ = cheerio.load(html);
    inky = new Inky();
    html = inky.releaseTheKraken($);

    // Apply the Styles Inline
    inlinedHtml = juice(html, {extraCss: css});

    // Add Additional attributes to HTML
    $ = cheerio.load(inlinedHtml);
    $('table').attr("border", "0");
    $('table').attr("cellpadding", "0");
    $('table').attr("cellspacing", "0");
    $('a').attr("target", "_blank");

    // Minify the File
    minifiedHtml = minify($.html(), {
      minifyCSS: true,
      collapseWhitespace: true
    });

    // Save the file
    fs.writeFile(targetPath, minifiedHtml, function(err) {
      if(err) {
        return console.log(err);
      }
      console.log("Template generated: " + targetPath);
    });
  }
})();
{'fraction_non_alphanumeric': 0.17897371714643304, 'fraction_numerical': 0.004693366708385482, 'mean_word_length': 3.0674300254452924, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, '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': '5028800', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1094, 'n_words': 261}