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 } }) }

@@ -121,29 +121,20 @@
  return 
-combine(
 diff
-)
 %0A    .re
@@ -169,24 +169,68 @@
  element) %7B%0A
+        var string = element.items.join('')%0A
         if (
@@ -286,24 +286,16 @@
 ('ins', 
-element.
 string) 
@@ -374,24 +374,16 @@
 ('del', 
-element.
 string) 
@@ -436,24 +436,16 @@
  escape(
-element.
 string) 
@@ -576,198 +576,4 @@
 ) %7D%0A
-%0Afunction combine(diff) %7B%0A  return diff%0A    .map(function(element) %7B%0A      return %7B%0A        string: element.items.join(''),%0A        added: element.added,%0A        removed: element.removed %7D %7D) %7D%0A

Simplify implementation