<commit_before>import ExternalLink from 'app/dim-ui/ExternalLink';
import { t } from 'app/i18next-t';
import clsx from 'clsx';
/* eslint-disable css-modules/no-unused-class */
import styles from './Description.m.scss';
import { LinesContent, Perk } from './descriptionInterface';

const customContent = (content: LinesContent) => {
  if (content.linkUrl) {
    return <ExternalLink href={content.linkUrl}>{content.linkText}</ExternalLink>;
  }
};

const joinClassNames = (classNames?: string) =>
  classNames
    ?.split(' ')
    .map((className) => styles[className])
    .join(' ');

/*
     (^|\b) : start from the beginning of the string or a word boundary
      [+-]? : include + or - prefixes
\d+(\.\d+)? : match numbers (including decimal values)
         x? : optionally match 'x' multiplier suffix
        ?:% : optionally include % suffix
       \b|$ : stop at a word boundary or the end of the string
*/
const boldTextRegEx = /(^|\b)(([+-]?\d+(\.\d+)?)x?)(?:%|\b|$)/g;

function applyFormatting(text: string) {
  const segments = [];

  const matches = [...text.matchAll(boldTextRegEx)];
  let startIndex = 0;
  let n = 0;
  for (const match of matches) {
    if (match.index === undefined) {
      continue;
    }
    const capturedText = match[0];
    segments.push(text.substring(startIndex, match.index));
    segments.push(<b key={n++}>{capturedText}</b>);
    startIndex = match.index + capturedText.length;
  }
  if (startIndex < text.length) {
    segments.push(text.substring(startIndex));<commit_msg>Adjust bold text regex to include 's', 'ms', 'HP', ° and + suffixes.<commit_after>import ExternalLink from 'app/dim-ui/ExternalLink';
import { t } from 'app/i18next-t';
import clsx from 'clsx';
/* eslint-disable css-modules/no-unused-class */
import styles from './Description.m.scss';
import { LinesContent, Perk } from './descriptionInterface';

const customContent = (content: LinesContent) => {
  if (content.linkUrl) {
    return <ExternalLink href={content.linkUrl}>{content.linkText}</ExternalLink>;
  }
};

const joinClassNames = (classNames?: string) =>
  classNames
    ?.split(' ')
    .map((className) => styles[className])
    .join(' ');

/*
       (^|\b) : start from the beginning of the string or a word boundary
        [+-]? : include + or - prefixes
  (\d*\.)?\d+ : match numbers (including decimal values)
([xs]|ms|HP)? : optionally include 'x' multiplier, 's', 'ms' and 'HP' unit suffixes
      ?:[%°+] : optionally include %, ° and + suffixes
         \b|$ : stop at a word boundary or the end of the string
*/
const boldTextRegEx = /(^|\b)([+-]?(\d*\.)?\d+([xs]|ms|HP)?)(?:[%°+]|\b|$)/g;

function applyFormatting(text: string) {
  const segments = [];

  const matches = [...text.matchAll(boldTextRegEx)];
  let startIndex = 0;
  let n = 0;
  for (const match of matches) {
    if (match.index === undefined) {
      continue;
    }
    const capturedText = match[0];
    segments.push(text.substring(startIndex, match.index));
    segments.push(<b key={n++}>{capturedText}</b>);
    startIndex = match.index + capturedText.length;
  }
  if (startIndex < text.length) {
    segments.push(text.substring(startIndex));
{'fraction_non_alphanumeric': 0.17678684376976597, 'fraction_numerical': 0.0031625553447185324, 'mean_word_length': 3.5510791366906473, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '3744562', 'n_tokens_mistral': 1043, 'n_tokens_neox': 1020, 'n_words': 264}