prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  La comparaison des versions a perdu sa sidebar
  ## Étapes pour reproduire 
  
  - prenez un tuto avec plusieurs éditions
  - cliquer sur "comparer les versions"
  - sélectionner deux versions
  
  **Comportement observé**
  
  la sidebar n'apparaît pas dans la page de comparaison des versions
  
  **Comportement désiré**
  
  La sidebar est là.
  
  </issue>
  <code>
  [start of zds/utils/templatetags/htmldiff.py]
  1 from difflib import HtmlDiff
  2 from django import template
  3 from django.utils.html import format_html
  4 from django.utils.safestring import mark_safe
  5 from django.utils.translation import ugettext_lazy as _
  6 
  7 
  8 register = template.Library()
  9 
  10 
  11 @register.simple_tag
  12 def htmldiff(string1, string2):
  13 
  14     try:
  15         txt1 = string1.decode('utf-8').splitlines()
  16     # string1 is an empty SafeText from template
  17     except AttributeError:
  18         txt1 = string1.splitlines()
  19 
  20     try:
  21         txt2 = string2.decode('utf-8').splitlines()
  22     except AttributeError:
  23         txt2 = string2.splitlines()
  24 
  25     diff = HtmlDiff(tabsize=4, wrapcolumn=80)
  26     result = diff.make_table(txt1, txt2, context=True, numlines=2)
  27 
  28     if 'No Differences Found' in result:
  29         return format_html('<p>{}</p>', _('Pas de changements.'))
  30     else:
  31         return format_html('<div class="diff_delta">{}</div>', mark_safe(result))
  32
  [end of zds/utils/templatetags/htmldiff.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/zds/utils/templatetags/htmldiff.py b/zds/utils/templatetags/htmldiff.py
  --- a/zds/utils/templatetags/htmldiff.py
  +++ b/zds/utils/templatetags/htmldiff.py
  @@ -22,10 +22,12 @@
       except AttributeError:
           txt2 = string2.splitlines()
   
  -    diff = HtmlDiff(tabsize=4, wrapcolumn=80)
  +    diff = HtmlDiff(tabsize=4)
       result = diff.make_table(txt1, txt2, context=True, numlines=2)
   
       if 'No Differences Found' in result:
           return format_html('<p>{}</p>', _('Pas de changements.'))
       else:
  -        return format_html('<div class="diff_delta">{}</div>', mark_safe(result))
  +        # the diff.make_table() replaces all spaces by non-breakable ones, which prevent line breaks:
  +        r = mark_safe(result.replace('<td nowrap="nowrap">', '<td>').replace('&nbsp;', ' '))
  +        return format_html('<div class="diff_delta">{}</div>', r)
  
verification_info: {"golden_diff": "diff --git a/zds/utils/templatetags/htmldiff.py b/zds/utils/templatetags/htmldiff.py\n--- a/zds/utils/templatetags/htmldiff.py\n+++ b/zds/utils/templatetags/htmldiff.py\n@@ -22,10 +22,12 @@\n     except AttributeError:\n         txt2 = string2.splitlines()\n \n-    diff = HtmlDiff(tabsize=4, wrapcolumn=80)\n+    diff = HtmlDiff(tabsize=4)\n     result = diff.make_table(txt1, txt2, context=True, numlines=2)\n \n     if 'No Differences Found' in result:\n         return format_html('<p>{}</p>', _('Pas de changements.'))\n     else:\n-        return format_html('<div class=\"diff_delta\">{}</div>', mark_safe(result))\n+        # the diff.make_table() replaces all spaces by non-breakable ones, which prevent line breaks:\n+        r = mark_safe(result.replace('<td nowrap=\"nowrap\">', '<td>').replace('&nbsp;', ' '))\n+        return format_html('<div class=\"diff_delta\">{}</div>', r)\n", "issue": "La comparaison des versions a perdu sa sidebar\n## \u00c9tapes pour reproduire \r\n\r\n- prenez un tuto avec plusieurs \u00e9ditions\r\n- cliquer sur \"comparer les versions\"\r\n- s\u00e9lectionner deux versions\r\n\r\n**Comportement observ\u00e9**\r\n\r\nla sidebar n'appara\u00eet pas dans la page de comparaison des versions\r\n\r\n**Comportement d\u00e9sir\u00e9**\r\n\r\nLa sidebar est l\u00e0.\n", "before_files": [{"content": "from difflib import HtmlDiff\nfrom django import template\nfrom django.utils.html import format_html\nfrom django.utils.safestring import mark_safe\nfrom django.utils.translation import ugettext_lazy as _\n\n\nregister = template.Library()\n\n\n@register.simple_tag\ndef htmldiff(string1, string2):\n\n    try:\n        txt1 = string1.decode('utf-8').splitlines()\n    # string1 is an empty SafeText from template\n    except AttributeError:\n        txt1 = string1.splitlines()\n\n    try:\n        txt2 = string2.decode('utf-8').splitlines()\n    except AttributeError:\n        txt2 = string2.splitlines()\n\n    diff = HtmlDiff(tabsize=4, wrapcolumn=80)\n    result = diff.make_table(txt1, txt2, context=True, numlines=2)\n\n    if 'No Differences Found' in result:\n        return format_html('<p>{}</p>', _('Pas de changements.'))\n    else:\n        return format_html('<div class=\"diff_delta\">{}</div>', mark_safe(result))\n", "path": "zds/utils/templatetags/htmldiff.py"}]}