<commit_before>import React from "react";
import ReactDOMServer from "react-dom/server";
import { EditorState, Modifier } from "draft-js";
import {
  convertToHTML as rawConvertToHTML,
  convertFromHTML as rawConvertFromHTML
} from "draft-convert";
import { CHECKABLE_LIST_ITEM_TYPE } from "./constants";

const convertToHTML = rawConvertToHTML({
  styleToHTML: style => {
    switch(style) {
      case "STRIKESTROUGH": 
        return <del />;
      case "MARK":
        return <mark />;
    }
  },
  blockToHTML: block => {
    if(block.type === CHECKABLE_LIST_ITEM_TYPE) {
      const checked = !! block.data.checked;
      const input = <input type="checkbox" defaultChecked={checked} />;

      return {
        start: "<li>" + ReactDOMServer.renderToStaticMarkup(input),
        end: "</li>",
        nest: <ul/>
      }
    };
  },
  entityToHTML: (entity, originalText) => {
    if (entity.type === "LINK") {
      return <a href={entity.data.url}>{originalText}</a>;
    }
    return originalText;
  }
});

const convertFromHTML = rawConvertFromHTML({
  htmlToStyle: (nodeName, _node, currentStyle) => {
    if (nodeName === "mark") {
      return currentStyle.add("MARK");
    } else {
      return currentStyle;
    }
  },
  htmlToEntity: (nodeName, node, createEntity) => {
    if (nodeName === "a") {
      return createLinkEntity(createEntity, node.href);
    }<commit_msg>Fix strikethrough serialization<commit_after>import React from "react";
import ReactDOMServer from "react-dom/server";
import { EditorState, Modifier } from "draft-js";
import {
  convertToHTML as rawConvertToHTML,
  convertFromHTML as rawConvertFromHTML
} from "draft-convert";
import { CHECKABLE_LIST_ITEM_TYPE } from "./constants";

const convertToHTML = rawConvertToHTML({
  styleToHTML: style => {
    switch(style) {
      case "STRIKETHROUGH": 
        return <del />;
      case "MARK":
        return <mark />;
    }
  },
  blockToHTML: block => {
    if(block.type === CHECKABLE_LIST_ITEM_TYPE) {
      const checked = !! block.data.checked;
      const input = <input type="checkbox" defaultChecked={checked} />;

      return {
        start: "<li>" + ReactDOMServer.renderToStaticMarkup(input),
        end: "</li>",
        nest: <ul/>
      }
    };
  },
  entityToHTML: (entity, originalText) => {
    if (entity.type === "LINK") {
      return <a href={entity.data.url}>{originalText}</a>;
    }
    return originalText;
  }
});

const convertFromHTML = rawConvertFromHTML({
  htmlToStyle: (nodeName, _node, currentStyle) => {
    switch(nodeName) {
      case "mark":
        return currentStyle.add("MARK");
      case "del":
        return currentStyle.add("STRIKETHROUGH");
      default:
        return currentStyle;
    }
  },
  htmlToEntity: (nodeName, node, createEntity) => {
    if (nodeName === "a") {
      return createLinkEntity(createEntity, node.href);
    }
{'fraction_non_alphanumeric': 0.14241055922195206, 'fraction_numerical': 0.0, 'mean_word_length': 3.0735502121640734, 'pattern_counts': {'":': 6, '<': 19, '<?xml version=': 0, '>': 29, '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': '1749569', 'n_tokens_mistral': 899, 'n_tokens_neox': 891, 'n_words': 198}