<commit_before>/* eslint-env node */

var fs = require('fs');
// var Feed = require('feed'); // to create feed objects and write them out
// var feedmerger = new require('./feedmerger.js').feedmerger; // our module to merge several feeds into one. Includes additional dependencies
var escapeMD = require('./escape-markdown.js').escapeMarkdown; // our module to escape markdown control characters
// var async = require('async'); // asyncjs for async stuff

exports.pagewriter = function(cat, jsonFeed) {
  'use strict';

  var theFeed = jsonFeed;
  var category = cat;
  console.log(category);

  var theOutput = '---\n' +
    'layout: page\n' +
    'title: Mathblogging.org | Category: "' + category + '"\n' +
    '---\n\n' // +
  ;

  var addEntries = function(resultFeed) {
    //   console.log(resultFeed.title);
    var newPart = '\n## ' + resultFeed.title + '\n\n';
    for (var i in resultFeed.items) {
      if (i > 9) {
        break;
      }
      var item = resultFeed.items[i];
      //     console.log(item.title);
      newPart += '* ' + '**' + escapeMD(item.author[0].name) + '**' + ' [' + escapeMD(item.title) + '](' + item.link + ')\n';
    }
    return newPart;
  };

  var doTheRest = function(feed) {
    theOutput += addEntries(feed);
    fs.writeFile('./mathblogging.org/' + category + '.md', theOutput);
    //   build out markdown now!
  };

  doTheRest(theFeed);
  // console.log(theFeed.render('atom-1.0'));
  return true;<commit_msg>enhance pagewriter: \n * write out xml for feed\n* add link to category feed to md\n* cleaner title and headings in md<commit_after>/* eslint-env node */

var fs = require('fs');
// var Feed = require('feed'); // to create feed objects and write them out
// var feedmerger = new require('./feedmerger.js').feedmerger; // our module to merge several feeds into one. Includes additional dependencies
var escapeMD = require('./escape-markdown.js').escapeMarkdown; // our module to escape markdown control characters
// var async = require('async'); // asyncjs for async stuff

exports.pagewriter = function(cat, jsonFeed) {
  'use strict';

  var theFeed = jsonFeed;
  var category = cat;
  console.log(category);

  var theOutput = '---\n' +
    'layout: page\n' +
    'title: ' + category + '\n' +
    '---\n\n' // +
  ;

  var addEntries = function(resultFeed) {
    //   console.log(resultFeed.title);
    // var newPart = '\n## ' + resultFeed.title + '\n\n';
    var newPart = '';
    for (var i in resultFeed.items) {
      if (i > 9) {
        break;
      }
      var item = resultFeed.items[i];
      //     console.log(item.title);
      newPart += '* ' + '**' + escapeMD(item.author[0].name) + '**' + ' [' + escapeMD(item.title) + '](' + item.link + ')\n';
    }
    newPart += '\n';
    newPart += '[Grab the feed for ' + cat + ' blogs!](' + cat + '.xml)\n';
    return newPart;
  };

  theOutput += addEntries(theFeed);
  fs.writeFile('./mathblogging.org/' + category + '.md', theOutput);
  //   build out markdown now!

  fs.writeFile('./mathblogging.org/' + cat + '.xml', theFeed.render('atom-1.0'));

  return true;
{'fraction_non_alphanumeric': 0.17843264248704663, 'fraction_numerical': 0.0025906735751295338, 'mean_word_length': 2.780905752753978, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 3}, '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': '4687592', 'n_tokens_mistral': 1021, 'n_tokens_neox': 994, 'n_words': 265}