<commit_before>module.exports = writeHtml;

var extend = require('xtend');
var fs = require('fs');
var hb = require('handlebars');
var marked = require('marked');
var path = require('path');
var slug = require('slugg');
var highlightjs = require('highlight.js');

marked.setOptions({
  highlight: function (code, lang) {
    return highlightjs.highlightAuto(code, [ lang ]).value;
  },
  langPrefix: 'hljs ' // le sigh: https://github.com/chjj/marked/pull/418
});

hb.registerHelper('markdown', function (data) {
  return new hb.SafeString(marked(data));
});

var toc = fs.readFileSync(path.join('template', 'toc.html'), {encoding: 'utf8'});
var page = fs.readFileSync(path.join('template', 'page.html'), {encoding: 'utf8'});
hb.registerPartial('toc', toc);
var genPage = hb.compile(page);

function writeHtml (passedOpts) {
  var opts = extend(passedOpts);

  opts.nav = opts.tocData.map(function (item) {
    return {url: slug(item) + '.html', title: item};
  });

  var output = genPage(opts);

  var name = slug(opts.name) + '.html';
  console.log('writing ' + name);
  fs.writeFileSync(path.join('build', name), output, {encoding: 'utf8'});
}<commit_msg>add custom slug function to make c++ cplusplus<commit_after>module.exports = writeHtml;

var extend = require('xtend');
var fs = require('fs');
var hb = require('handlebars');
var marked = require('marked');
var path = require('path');
var slug = require('slugg');
var highlightjs = require('highlight.js');

marked.setOptions({
  highlight: function (code, lang) {
    return highlightjs.highlightAuto(code, [ lang ]).value;
  },
  langPrefix: 'hljs ' // le sigh: https://github.com/chjj/marked/pull/418
});

hb.registerHelper('markdown', function (data) {
  return new hb.SafeString(marked(data));
});

var toc = fs.readFileSync(path.join('template', 'toc.html'), {encoding: 'utf8'});
var page = fs.readFileSync(path.join('template', 'page.html'), {encoding: 'utf8'});
hb.registerPartial('toc', toc);
var genPage = hb.compile(page);

function writeHtml (passedOpts) {
  var opts = extend(passedOpts);

  opts.nav = opts.tocData.map(function (item) {
    return {url: customSlug(item) + '.html', title: item};
  });

  var output = genPage(opts);

  var name = customSlug(opts.name) + '.html';
  console.log('writing ' + name);
  fs.writeFileSync(path.join('build', name), output, {encoding: 'utf8'});
}

function customSlug (name) {
  var customName = name.replace(/\+/g, 'plus');
  return slug(customName);
}
{'fraction_non_alphanumeric': 0.1874493927125506, 'fraction_numerical': 0.004858299595141701, 'mean_word_length': 5.041564792176039, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5791081', 'n_tokens_mistral': 861, 'n_tokens_neox': 816, 'n_words': 194}