<commit_before>// @flow

/* eslint jsx-a11y/no-static-element-interactions: 0 */

import React from "react";
import CommonMark from "commonmark";
import MarkdownRenderer from "commonmark-react-renderer";

import Editor from "../../providers/editor";
import LatexRenderer from "../latex";

import { Outputs, PromptBuffer, Input } from "../ng";

type Props = {
  cell: any,
  focusAbove: () => void,
  focusBelow: () => void,
  focusEditor: Function,
  cellFocused: boolean,
  editorFocused: boolean,
  children: React$Element<*>
};

type State = {
  view: boolean
};

type MDRender = (input: string) => string;

const parser = new CommonMark.Parser();
const renderer = new MarkdownRenderer();

const mdRender: MDRender = input => renderer.render(parser.parse(input));

export default class MarkdownCell extends React.PureComponent<any, State> {
  openEditor: () => void;
  editorKeyDown: (e: SyntheticKeyboardEvent<*>) => void;
  renderedKeyDown: (e: SyntheticKeyboardEvent<*>) => boolean;
  rendered: ?HTMLElement;

  static defaultProps = {
    cellFocused: false
  };

  constructor(props: Props): void {
    super(props);
    this.state = {
      view: true
    };
    this.openEditor = this.openEditor.bind(this);
    this.editorKeyDown = this.editorKeyDown.bind(this);
    this.renderedKeyDown = this.renderedKeyDown.bind(this);
  }

  componentDidMount(): void {<commit_msg>work around contravariant function type issue<commit_after>// @flow

/* eslint jsx-a11y/no-static-element-interactions: 0 */

import React from "react";
import CommonMark from "commonmark";
import MarkdownRenderer from "commonmark-react-renderer";

import Editor from "../../providers/editor";
import LatexRenderer from "../latex";

import { Outputs, PromptBuffer, Input } from "../ng";

type Props = {
  cell: any,
  focusAbove: () => void,
  focusBelow: () => void,
  focusEditor: Function,
  cellFocused: boolean,
  editorFocused: boolean,
  children: React$Element<*>
};

type State = {
  view: boolean
};

// TODO: Standardize this as @nteract/markdown-renderer
//       and keep it consistent amongst the markdown transform and in the
//       rendered view of markdown cells
type MDRender = (input: string) => string;
const parser = new CommonMark.Parser();
const renderer = new MarkdownRenderer();
const mdRender: MDRender = input => renderer.render(parser.parse(input));

export default class MarkdownCell extends React.PureComponent<any, State> {
  rendered: ?HTMLElement;

  static defaultProps = {
    cellFocused: false
  };

  constructor(props: Props): void {
    super(props);
    this.state = {
      view: true
    };
    (this: any).openEditor = this.openEditor.bind(this);
    (this: any).editorKeyDown = this.editorKeyDown.bind(this);
    (this: any).renderedKeyDown = this.renderedKeyDown.bind(this);
  }

  componentDidMount(): void {
{'fraction_non_alphanumeric': 0.13359182234755024, 'fraction_numerical': 0.0021149101163200562, 'mean_word_length': 4.113513513513514, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 20, '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': '5930300', 'n_tokens_mistral': 886, 'n_tokens_neox': 868, 'n_words': 233}