<commit_before>import * as React from 'react'

interface IAccessTextProps {
  readonly text: string,
  readonly highlight?: boolean,
}

/**
 * A platform helper function which optionally highlights access keys (letters
 * prefixed with &) on Windows. On non-Windows platform access key prefixes
 * are removed before rendering.
 */
export class AccessText extends React.Component<IAccessTextProps, void> {
  public shouldComponentUpdate(nextProps: IAccessTextProps) {
    return this.props.text !== nextProps.text ||
      this.props.highlight !== nextProps.highlight
  }

  public render() {
    if (this.props.highlight) {
      // Match everything (if anything) before an ampersand followed by anything that's
      // not an ampersand and then capture the remainder.
      const m = this.props.text.match(/^(.*?)?(?:&([^&]))(.*)?$/)
      const elements = new Array<JSX.Element>()

      if (m) {

        if (m[1]) {
          elements.push(<span key={1}>{m[1]}</span>)
        }

        elements.push(<span key={2} className='access-key highlight'>{m[2]}</span>)

        if (m[3]) {
          elements.push(<span key={3}>{m[3]}</span>)<commit_msg>Unescape escaped ampersands<commit_after>import * as React from 'react'

interface IAccessTextProps {
  readonly text: string,
  readonly highlight?: boolean,
}

/**
 * A platform helper function which optionally highlights access keys (letters
 * prefixed with &) on Windows. On non-Windows platform access key prefixes
 * are removed before rendering.
 */
export class AccessText extends React.Component<IAccessTextProps, void> {
  public shouldComponentUpdate(nextProps: IAccessTextProps) {
    return this.props.text !== nextProps.text ||
      this.props.highlight !== nextProps.highlight
  }

  public render() {
    if (this.props.highlight) {
      // Match everything (if anything) before an ampersand followed by anything that's
      // not an ampersand and then capture the remainder.
      const m = this.props.text.match(/^(.*?)?(?:&([^&]))(.*)?$/)
      const elements = new Array<JSX.Element>()

      if (m) {

        if (m[1]) {
          elements.push(<span key={1}>{m[1].replace('&&', '&')}</span>)
        }

        elements.push(<span key={2} className='access-key highlight'>{m[2]}</span>)

        if (m[3]) {
          elements.push(<span key={3}>{m[3].replace('&&', '&')}</span>)
{'fraction_non_alphanumeric': 0.15156646909398813, 'fraction_numerical': 0.006773920406435224, 'mean_word_length': 3.319926873857404, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '6249580', 'n_tokens_mistral': 712, 'n_tokens_neox': 681, 'n_words': 193}