<commit_before>import React from 'react';
import MathJax from 'react-mathjax';
import ReactMarkdown from 'react-markdown';

// needed to get "markdown-body" in scope
// eslint-disable-next-line no-unused-vars
import MarkdownElement from 'react-material-markdown-element';

import { markdownPropTypes } from './constants';


const texKeyword = 'tex';

function HtmlCodeBlock(literal, inline) {
  const code = React.createElement('code', {}, literal);
  return inline ? code : React.createElement('pre', {}, code);
}

function Code(props) {
  if (props.literal.substring(0, texKeyword.length) === texKeyword) {
    return <MathJax.Node inline>{props.literal.substring(texKeyword.length + 1, props.literal.length)}</MathJax.Node>;
  }

  return HtmlCodeBlock(props.literal, true);
}
Code.propTypes = {
  literal: React.PropTypes.string.isRequired,
};

function CodeBlock(props) {
  if (props.language === texKeyword) {
    return <MathJax.Node>{props.literal}</MathJax.Node>;
  }

  return HtmlCodeBlock(props.literal);
}
CodeBlock.propTypes = {
  language: React.PropTypes.string.isRequired,
  literal: React.PropTypes.string.isRequired,
};

function Markdown(props) {
  const { text } = props;
  return (
    <div
      className="markdown-body"
    >
      <MathJax.Context>
        <ReactMarkdown source={text} renderers={{ code: Code, code_block: CodeBlock }} />
      </MathJax.Context><commit_msg>Switch mathjax source to cdnjs<commit_after>import React from 'react';
import MathJax from 'react-mathjax';
import ReactMarkdown from 'react-markdown';

// needed to get "markdown-body" in scope
// eslint-disable-next-line no-unused-vars
import MarkdownElement from 'react-material-markdown-element';

import { markdownPropTypes } from './constants';


const texKeyword = 'tex';

function HtmlCodeBlock(literal, inline) {
  const code = React.createElement('code', {}, literal);
  return inline ? code : React.createElement('pre', {}, code);
}

function Code(props) {
  if (props.literal.substring(0, texKeyword.length) === texKeyword) {
    return <MathJax.Node inline>{props.literal.substring(texKeyword.length + 1, props.literal.length)}</MathJax.Node>;
  }

  return HtmlCodeBlock(props.literal, true);
}
Code.propTypes = {
  literal: React.PropTypes.string.isRequired,
};

function CodeBlock(props) {
  if (props.language === texKeyword) {
    return <MathJax.Node>{props.literal}</MathJax.Node>;
  }

  return HtmlCodeBlock(props.literal);
}
CodeBlock.propTypes = {
  language: React.PropTypes.string.isRequired,
  literal: React.PropTypes.string.isRequired,
};

function Markdown(props) {
  const { text } = props;
  return (
    <div
      className="markdown-body"
    >
      <MathJax.Context script="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML">
        <ReactMarkdown source={text} renderers={{ code: Code, code_block: CodeBlock }} />
      </MathJax.Context>
{'fraction_non_alphanumeric': 0.14334705075445817, 'fraction_numerical': 0.0024005486968449933, 'mean_word_length': 4.442164179104478, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 1, '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': '3081038', 'n_tokens_mistral': 934, 'n_tokens_neox': 933, 'n_words': 186}