<commit_before>// # Excerpt Helper
// Usage: `{{excerpt}}`, `{{excerpt words="50"}}`, `{{excerpt characters="256"}}`
//
// Attempts to remove all HTML from the string, and then shortens the result according to the provided option.
//
// Defaults to words="50"

var proxy = require('./proxy'),
    _ = require('lodash'),
    SafeString = proxy.SafeString,
    getMetaDataExcerpt = proxy.metaData.getMetaDataExcerpt;

/**
 * @NOTE:
 *
 * Content API v2 returns a calculated `post.excerpt` field.
 * See https://github.com/TryGhost/Ghost/issues/10062.
 * We have not touched this helper yet, we will revisit later.
 *
 * @TODO: remove or change if we drop v0.1
 */
module.exports = function excerpt(options) {
    var truncateOptions = (options || {}).hash || {},
        excerptText = this.custom_excerpt ? String(this.custom_excerpt) : String(this.html);

    truncateOptions = _.pick(truncateOptions, ['words', 'characters']);
    _.keys(truncateOptions).map(function (key) {
        truncateOptions[key] = parseInt(truncateOptions[key], 10);
    });

    if (!_.isEmpty(this.custom_excerpt)) {
        truncateOptions.characters = this.custom_excerpt.length;
        if (truncateOptions.words) {
            delete truncateOptions.words;
        }
    }

    return new SafeString(
        getMetaDataExcerpt(excerptText, truncateOptions)
    );
};<commit_msg>🐛 Fixed returning 'null' text for exerpt helper<commit_after>// # Excerpt Helper
// Usage: `{{excerpt}}`, `{{excerpt words="50"}}`, `{{excerpt characters="256"}}`
//
// Attempts to remove all HTML from the string, and then shortens the result according to the provided option.
//
// Defaults to words="50"

var proxy = require('./proxy'),
    _ = require('lodash'),
    SafeString = proxy.SafeString,
    getMetaDataExcerpt = proxy.metaData.getMetaDataExcerpt;

/**
 * @NOTE:
 *
 * Content API v2 returns a calculated `post.excerpt` field.
 * See https://github.com/TryGhost/Ghost/issues/10062.
 * We have not touched this helper yet, we will revisit later.
 *
 * @TODO: remove or change if we drop v0.1
 */
module.exports = function excerpt(options) {
    var truncateOptions = (options || {}).hash || {},
        excerptText = this.custom_excerpt
            ? String(this.custom_excerpt)
            : this.html
                ? String(this.html)
                : '';

    truncateOptions = _.pick(truncateOptions, ['words', 'characters']);
    _.keys(truncateOptions).map(function (key) {
        truncateOptions[key] = parseInt(truncateOptions[key], 10);
    });

    if (!_.isEmpty(this.custom_excerpt)) {
        truncateOptions.characters = this.custom_excerpt.length;
        if (truncateOptions.words) {
            delete truncateOptions.words;
        }
    }

    return new SafeString(
        getMetaDataExcerpt(excerptText, truncateOptions)
    );
};
{'fraction_non_alphanumeric': 0.13856486390950867, 'fraction_numerical': 0.012018381053375752, 'mean_word_length': 3.1802067946824226, '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': '7634438', 'n_tokens_mistral': 922, 'n_tokens_neox': 851, 'n_words': 210}