<commit_before>// DecentCMS (c) 2014 <NAME>, under MIT. See LICENSE.txt for licensing details.
'use strict';
var path = require('path');

function TextPart(shell, options) {
  this.shell = shell;
  this.item = options.item;
}

TextPart.on = {
  'decent.core.handle-item': function(shell, options) {
    var content = options.shape;
    if (!content.meta
      || content.meta.type !== 'content'
      || !content.temp
      || !content.temp.item
      || !content.temp.item.title) return;
    var temp = content.temp;
    var item = temp.item;
    var renderer = options.renderStream;
    var contentManager = renderer.contentManager;
    var textParts = contentManager.getParts(item, 'text');
    for (var i = 0; i < textParts.length; i++) {
      var partName = textParts[i];
      var part = item[partName];
      var text = part.text;
      if (!text && part._data) {
        text = part._data;
      }
      var flavor = part.flavor
        || (part.path ? path.extname(part.path).substr(1) : 'plain-text');
      temp.shapes.push({
        meta: {type: 'text', name: partName},
        temp: {displayType: temp.displayType},
        text: text,
        flavor: flavor
      });
    }
  }<commit_msg>Removed some unfortunate copy-pasted code from text part handler.<commit_after>// DecentCMS (c) 2014 <NAME>, under MIT. See LICENSE.txt for licensing details.
'use strict';
var path = require('path');

function TextPart(shell, options) {
  this.shell = shell;
  this.item = options.item;
}

TextPart.on = {
  'decent.core.handle-item': function(shell, options) {
    var content = options.shape;
    if (!content.meta
      || content.meta.type !== 'content'
      || !content.temp) return;
    var temp = content.temp;
    var item = temp.item;
    var renderer = options.renderStream;
    var contentManager = renderer.contentManager;
    var textParts = contentManager.getParts(item, 'text');
    for (var i = 0; i < textParts.length; i++) {
      var partName = textParts[i];
      var part = item[partName];
      var text = part.text;
      if (!text && part._data) {
        text = part._data;
      }
      var flavor = part.flavor
        || (part.path ? path.extname(part.path).substr(1) : 'plain-text');
      temp.shapes.push({
        meta: {type: 'text', name: partName},
        temp: {displayType: temp.displayType},
        text: text,
        flavor: flavor
      });
    }
  }
{'fraction_non_alphanumeric': 0.14458333333333334, 'fraction_numerical': 0.005, 'mean_word_length': 2.6268882175226587, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '6628054', 'n_tokens_mistral': 769, 'n_tokens_neox': 755, 'n_words': 196}