title: Side by side html diff_match_patch
body: <pre><code>import diff_match_patch
  
  old_string = """I'm selfish, impatient and a little insecure. I make mistakes,
  I am out of control and at times hard to handle. But if you can't handle me at my worst,
  then you sure as hell don't deserve me at my best."""
  
  new_string = """I'm selfish, impatient and a little secure. I don't make mistakes,
  I am out of control and at times hard to handle difficult things. But if you can't handle me at my worst,
  then you sure as hell don't deserve me at my best."""
  
  class SideBySideDiff(diff_match_patch.diff_match_patch):
  
      def old_content(self, diffs):
          """
          Returns HTML representation of 'deletions'
          """
          html = []
          for (flag, data) in diffs:
              text = (data.replace("&amp;", "&amp;amp;")
                      .replace("&lt;", "&amp;lt;")
                      .replace("&gt;", "&amp;gt;")
                      .replace("\n", "&lt;br&gt;"))
  
              if flag == self.DIFF_DELETE:
                  html.append("""&lt;del style=\"background:#ffe6e6;
                      \"&gt;%s&lt;/del&gt;""" % text)
              elif flag == self.DIFF_EQUAL:
                  html.append("&lt;span&gt;%s&lt;/span&gt;" % text)
          return "".join(html)
  
      def new_content(self, diffs):
          """
          Returns HTML representation of 'insertions'
          """
          html = []
          for (flag, data) in diffs:
              text = (data.replace("&amp;", "&amp;amp;")
                      .replace("&lt;", "&amp;lt;")
                      .replace("&gt;", "&amp;gt;")
                      .replace("\n", "&lt;br&gt;"))
              if flag == self.DIFF_INSERT:
                  html.append("""&lt;ins style=\"background:#e6ffe6;
                      \"&gt;%s&lt;/ins&gt;""" % text)
              elif flag == self.DIFF_EQUAL:
                  html.append("&lt;span&gt;%s&lt;/span&gt;" % text)
          return "".join(html)
  
  
  
  diff_obj = SideBySideDiff()
  result = diff_obj.diff_main(old_string, new_string)
  diff_obj.diff_cleanupSemantic(result)
  
  diffs = diff_obj.diff_main(old_string, new_string)
  old_record = diff_obj.old_content(result) 
  new_record = diff_obj.new_content(result)
  </code></pre>
  
  <p>However, as in the example of</p>
  
  <blockquote>
    <p><a href="http://agiliq.com/blog/2014/05/google-diff-match-patch-library/" rel="nofollow noreferrer">http://agiliq.com/blog/2014/05/google-diff-match-patch-library/</a></p>
  </blockquote>
  
  <p>I cannot seem to get it working that it shows the results side by side in a HTML file. How is it possible for me to fix this?</p>