<commit_before>/**
 * @copyright   2016, <NAME>
 * @license     https://opensource.org/licenses/MIT
 * @flow
 */

import React from 'react';
import PropTypes from 'prop-types';
import Parser from './Parser';
import Element from './components/Element';

type MarkupProps = {
  content: string,
  disableLineBreaks: boolean,
  disableWhitelist: boolean,
  emptyContent: ?React$Node,
  noHtml: boolean,
  noHtmlExceptMatchers: boolean,
  tagName: string,
};

export default function Markup({
  content,
  emptyContent,
  disableLineBreaks,
  disableWhitelist,
  tagName,
  noHtml,
  noHtmlExceptMatchers,
}: MarkupProps) {
  const className = (noHtml || noHtmlExceptMatchers) ? 'interweave--no-html' : '';
  const markup = new Parser(content, {
    noHtml,
    noHtmlExceptMatchers,
    disableLineBreaks,
    disableWhitelist,
  }).parse();

  return (
    <Element tagName={tagName} className={className}>
      {markup.length ? markup : (emptyContent || null)}
    </Element>
  );
}

Markup.propTypes = {
  content: PropTypes.string,
  disableLineBreaks: PropTypes.bool,
  disableWhitelist: PropTypes.bool,
  emptyContent: PropTypes.node,
  noHtml: PropTypes.bool,
  noHtmlExceptMatchers: PropTypes.bool,
  tagName: PropTypes.oneOf(['span', 'div', 'p']),
};

Markup.defaultProps = {
  content: '',
  disableLineBreaks: false,
  disableWhitelist: false,
  emptyContent: null,
  noHtml: false,
  noHtmlExceptMatchers: false,
  tagName: 'span',
};<commit_msg>[core] Converted Markup to a pure component.<commit_after>/**
 * @copyright   2016, <NAME>
 * @license     https://opensource.org/licenses/MIT
 * @flow
 */

import React from 'react';
import PropTypes from 'prop-types';
import Parser from './Parser';
import Element from './components/Element';

type MarkupProps = {
  content: string,
  disableLineBreaks: boolean,
  disableWhitelist: boolean,
  emptyContent: ?React$Node,
  noHtml: boolean,
  noHtmlExceptMatchers: boolean,
  tagName: string,
};

export default class Markup extends React.PureComponent<MarkupProps> {
  static propTypes = {
    content: PropTypes.string,
    disableLineBreaks: PropTypes.bool,
    disableWhitelist: PropTypes.bool,
    emptyContent: PropTypes.node,
    noHtml: PropTypes.bool,
    noHtmlExceptMatchers: PropTypes.bool,
    tagName: PropTypes.oneOf(['span', 'div', 'p']),
  };

  static defaultProps = {
    content: '',
    disableLineBreaks: false,
    disableWhitelist: false,
    emptyContent: null,
    noHtml: false,
    noHtmlExceptMatchers: false,
    tagName: 'span',
  };

  render() {
    const {
      content,
      noHtml,
      noHtmlExceptMatchers,
      disableLineBreaks,
      disableWhitelist,
      emptyContent,
      tagName,
    } = this.props;
    const className = (noHtml || noHtmlExceptMatchers) ? 'interweave--no-html' : '';
    const markup = new Parser(content, {
      noHtml,
      noHtmlExceptMatchers,
      disableLineBreaks,
      disableWhitelist,
    }).parse();

    return (
      <Element tagName={tagName} className={className}>
        {markup.length ? markup : emptyContent}
      </Element>
    );
  }
}
{'fraction_non_alphanumeric': 0.12297734627831715, 'fraction_numerical': 0.0025889967637540453, 'mean_word_length': 3.6691842900302114, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '4207774', 'n_tokens_mistral': 994, 'n_tokens_neox': 974, 'n_words': 221}