<commit_before>"use strict";

/* eslint camelcase:off */

const ArgHandler = require("./ArgHandler");
const _ = require("lodash");
const xmlq = require("./xmlq");
const colorIndexes = require("./colorIndexes");

/**
 * Rich text.
 * @ignore
 */
class RichText {
    /**
     * Creates a new instance of RichText.
     * @constructor
     * @param {string} value - text value
     * @param {object|undefined|null} styles - multiple styles
     * @param {Cell|undefined|null} cell - the cell that display the rich text
     */
    constructor(value, styles, cell) {
        if (value.name === 'r') {
            this._node = value;
            this._fontNode = xmlq.findChild(this._node, 'rPr');
        } else {
            value = value.replace(/((?<!\r)\n)|\r(?!\n)/g, '\r\n');
            const hasLineSeparator = value.indexOf('\r\n') !== -1;
            this._node = {
                name: 'r',
                attributes: {},
                children: [
                    { name: 'rPr', attributes: {}, children: [] },
                    { name: 't', attributes: hasLineSeparator ? { 'xml:space': 'preserve' } : {}, children: [value] }
                ]
            };
            this._fontNode = xmlq.findChild(this._node, 'rPr');

            // add styles
            this.style(styles);
            // set wrapText = true if it contains line separator, excel will only display new lines if it sets.
            if (cell && hasLineSeparator) {<commit_msg>replace negated lookbehind with a compatible way<commit_after>"use strict";

/* eslint camelcase:off */

const ArgHandler = require("./ArgHandler");
const _ = require("lodash");
const xmlq = require("./xmlq");
const colorIndexes = require("./colorIndexes");

/**
 * Rich text.
 * @ignore
 */
class RichText {
    /**
     * Creates a new instance of RichText.
     * @constructor
     * @param {string} value - text value
     * @param {object|undefined|null} styles - multiple styles
     * @param {Cell|undefined|null} cell - the cell that display the rich text
     */
    constructor(value, styles, cell) {
        if (value.name === 'r') {
            this._node = value;
            this._fontNode = xmlq.findChild(this._node, 'rPr');
        } else {
            value = value.replace(/(?:\r\n|\r|\n)/g, '\r\n');
            const hasLineSeparator = value.indexOf('\r\n') !== -1;
            this._node = {
                name: 'r',
                attributes: {},
                children: [
                    { name: 'rPr', attributes: {}, children: [] },
                    { name: 't', attributes: hasLineSeparator ? { 'xml:space': 'preserve' } : {}, children: [value] }
                ]
            };
            this._fontNode = xmlq.findChild(this._node, 'rPr');

            // add styles
            this.style(styles);
            // set wrapText = true if it contains line separator, excel will only display new lines if it sets.
            if (cell && hasLineSeparator) {
{'fraction_non_alphanumeric': 0.15177065767284992, 'fraction_numerical': 0.0006745362563237774, 'mean_word_length': 1.9164208456243854, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '2077776', 'n_tokens_mistral': 847, 'n_tokens_neox': 828, 'n_words': 224}