<commit_before>var mongoose = require('mongoose'),
    extend = require('mongoose-schema-extend'),
    log = require('./log'),
    env = process.env.NODE_ENV || 'development',   
    config = require('../../config/config')[env],
    util = require('util'),
    md = require('node-markdown').Markdown;

var NamesLogSchema = log.LogSchema.extend({
    nicks: [String]
});

function irssi(namesLog, markdown) {
    markdown = markdown || false;

    var usersChannelPrint = '[Users %s]';
    if (markdown) usersChannel = '[Users **%s**]';
    var usersChannel = util.format(usersChannelPrint, namesLog.channel);

    var users = '';
    var numOps = 0;
    var numHalfops = 0;
    var numVoices = 0;
    var numNormal = 0;
    var numTotal = 0;
    namesLog.nicks.forEach(function(nick) {
	var access = nick.charAt(0);
	switch(access) {
	case '@':
	    numOps++;
	    users += util.format('[%s] ', nick);
	    break;
	case '%':
	    numHalfops++;
	    users += util.format('[%s] ', nick);
	    break;
	case '+':
	    numVoices++;
	    users += util.format('[%s] ', nick);
	    break;
	default:
	    numNormal++;
	    users += util.format('[ %s] ', nick);
	};
	numTotal++;
    });

    var countPrint = '-!- %s: %s: Total of %d nicks [%d ops, %d halfops, %d voices, %d normal]';
    if (markdown) countPrint = '-!- **%s**: **%s**: Total of **%d** nicks [**%d** ops, **%d** halfops, **%d** voices, **%d** normal]';
    var count = util.format(countPrint, config.irc.nick, namesLog.channel, numTotal, numOps, numHalfops, numVoices, numNormal);
    
    return util.format('%s\n%s\n%s', usersChannel, users, count);
};

NamesLogSchema.virtual('irssi').get(function() {
    return irssi(this);
});

NamesLogSchema.virtual('irssi_markdown').get(function() {
    return md(irssi(this, true), true, 'strong|em');
});

mongoose.model('NamesLog', NamesLogSchema);
<commit_msg>fix nameslog newlines in markdown<commit_after>var mongoose = require('mongoose'),
    extend = require('mongoose-schema-extend'),
    log = require('./log'),
    env = process.env.NODE_ENV || 'development',   
    config = require('../../config/config')[env],
    util = require('util'),
    md = require('node-markdown').Markdown;

var NamesLogSchema = log.LogSchema.extend({
    nicks: [String]
});

function irssi(namesLog, markdown) {
    markdown = markdown || false;

    var usersChannelPrint = '[Users %s]';
    if (markdown) usersChannel = '[Users **%s**]';
    var usersChannel = util.format(usersChannelPrint, namesLog.channel);

    var users = '';
    var numOps = 0;
    var numHalfops = 0;
    var numVoices = 0;
    var numNormal = 0;
    var numTotal = 0;
    namesLog.nicks.forEach(function(nick) {
	var access = nick.charAt(0);
	switch(access) {
	case '@':
	    numOps++;
	    users += util.format('[%s] ', nick);
	    break;
	case '%':
	    numHalfops++;
	    users += util.format('[%s] ', nick);
	    break;
	case '+':
	    numVoices++;
	    users += util.format('[%s] ', nick);
	    break;
	default:
	    numNormal++;
	    users += util.format('[ %s] ', nick);
	};
	numTotal++;
    });

    var countPrint = '-!- %s: %s: Total of %d nicks [%d ops, %d halfops, %d voices, %d normal]';
    if (markdown) countPrint = '-!- **%s**: **%s**: Total of **%d** nicks [**%d** ops, **%d** halfops, **%d** voices, **%d** normal]';
    var count = util.format(countPrint, config.irc.nick, namesLog.channel, numTotal, numOps, numHalfops, numVoices, numNormal);
    
    var result = util.format('%s\n%s\n%s', usersChannel, users, count);
    if (markdown) result = util.format('%s  \n%s  \n%s', usersChannel, users, count);
    return result;
};

NamesLogSchema.virtual('irssi').get(function() {
    return irssi(this);
});

NamesLogSchema.virtual('irssi_markdown').get(function() {
    return md(irssi(this, true), true, 'strong|em|br');
});

mongoose.model('NamesLog', NamesLogSchema);

{'fraction_non_alphanumeric': 0.19689119170984457, 'fraction_numerical': 0.0031088082901554403, 'mean_word_length': 3.46875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5592950', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1332, 'n_words': 308}