<commit_before>import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import ReactMarkdown from 'react-markdown';
import RemarkDisableTokenizers from 'remark-disable-tokenizers';
import urbitOb from 'urbit-ob';
import { Text } from '@tlon/indigo-react';

const DISABLED_BLOCK_TOKENS = [
  'indentedCode',
  'atxHeading',
  'thematicBreak',
  'list',
  'setextHeading',
  'html',
  'definition',
  'table'
];

const DISABLED_INLINE_TOKENS = [
  'autoLink',
  'url',
  'email',
  'link',
  'reference'
];

const renderers = {
  inlineCode: ({language, value}) => {
    return <Text mono p='1' backgroundColor='washedGray' style={{ whiteSpace: 'preWrap'}}>{value}</Text>
  },
  code: ({language, value}) => {
    return <Text
              p='1'
              className='clamp-message'
              display='block'
              borderRadius='1'
              mono
              backgroundColor='washedGray'
              overflowX='scroll'
              style={{ whiteSpace: 'pre'}}>
              {value}
            </Text>
  }
};

const MessageMarkdown = React.memo(props => (
  <ReactMarkdown
    {...props}
    unwrapDisallowed={true}
    renderers={renderers}
    allowNode={(node, index, parent) => {
      if (
        node.type === 'blockquote'
        && parent.type === 'root'
        && node.children.length
        && node.children[0].type === 'paragraph'
        && node.children[0].position.start.offset < 2
      ) {
        node.children[0].children[0].value = '>' + node.children[0].children[0].value;
        return false;
      }

      return true;
    }}
    plugins={[[
      RemarkDisableTokenizers,<commit_msg>chat: centre code block text<commit_after>import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import ReactMarkdown from 'react-markdown';
import RemarkDisableTokenizers from 'remark-disable-tokenizers';
import urbitOb from 'urbit-ob';
import { Text } from '@tlon/indigo-react';

const DISABLED_BLOCK_TOKENS = [
  'indentedCode',
  'atxHeading',
  'thematicBreak',
  'list',
  'setextHeading',
  'html',
  'definition',
  'table'
];

const DISABLED_INLINE_TOKENS = [
  'autoLink',
  'url',
  'email',
  'link',
  'reference'
];

const renderers = {
  inlineCode: ({language, value}) => {
    return <Text mono p='1' backgroundColor='washedGray' style={{ whiteSpace: 'preWrap'}}>{value}</Text>
  },
  code: ({language, value}) => {
    return <Text
              p='1'
              className='clamp-message'
              display='block'
              borderRadius='1'
              mono
              backgroundColor='washedGray'
              overflowX='auto'
              style={{ whiteSpace: 'pre'}}>
              {value}
            </Text>
  }
};

const MessageMarkdown = React.memo(props => (
  <ReactMarkdown
    {...props}
    unwrapDisallowed={true}
    renderers={renderers}
    allowNode={(node, index, parent) => {
      if (
        node.type === 'blockquote'
        && parent.type === 'root'
        && node.children.length
        && node.children[0].type === 'paragraph'
        && node.children[0].position.start.offset < 2
      ) {
        node.children[0].children[0].value = '>' + node.children[0].children[0].value;
        return false;
      }

      return true;
    }}
    plugins={[[
      RemarkDisableTokenizers,
{'fraction_non_alphanumeric': 0.15612825891519327, 'fraction_numerical': 0.005993407252022775, 'mean_word_length': 2.5397667020148464, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, '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': '2402207', 'n_tokens_mistral': 1060, 'n_tokens_neox': 1047, 'n_words': 203}