<commit_before>module.exports = genericDiffToHTML5

var escape = require('html-escaping').escape

function genericDiffToHTML5(diff) {
  return combine(diff)
    .reduce(
      function(result, element) {
        if (element.added) {
          return ( result + wrap('ins', element.string) ) }
        else if (element.removed) {
          return ( result + wrap('del', element.string) ) }
        else {
          return ( result + escape(element.string) ) } },
      '') }

function wrap(tag, string) {
  return (
    '<' + tag + '>' +
    escape(string) +
    '</' + tag + '>' ) }

function combine(diff) {
  return diff
    .map(function(element) {
      return {
        string: element.items.join(''),
        added: element.added,
        removed: element.removed } }) }<commit_msg>Simplify implementation<commit_after>module.exports = genericDiffToHTML5

var escape = require('html-escaping').escape

function genericDiffToHTML5(diff) {
  return diff
    .reduce(
      function(result, element) {
        var string = element.items.join('')
        if (element.added) {
          return ( result + wrap('ins', string) ) }
        else if (element.removed) {
          return ( result + wrap('del', string) ) }
        else {
          return ( result + escape(string) ) } },
      '') }

function wrap(tag, string) {
  return (
    '<' + tag + '>' +
    escape(string) +
    '</' + tag + '>' ) }
{'fraction_non_alphanumeric': 0.1525302922309337, 'fraction_numerical': 0.002851033499643621, 'mean_word_length': 2.3995157384987893, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2687324', 'n_tokens_mistral': 422, 'n_tokens_neox': 427, 'n_words': 88}