prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Format event description
  As a planner, I want to be able to format the event description. This should at least mean that links will be formatted so that they are clickable. Maybe this should mean that the description will accept Markdown.
  
  </issue>
  <code>
  [start of ephios/extra/templatetags/rich_text.py]
  1 import bleach
  2 import markdown
  3 from django import template
  4 from django.utils.safestring import mark_safe
  5 
  6 register = template.Library()
  7 
  8 ALLOWED_TAGS = [
  9     "a",
  10     "abbr",
  11     "acronym",
  12     "b",
  13     "blockquote",
  14     "br",
  15     "code",
  16     "div",
  17     "em",
  18     "h1",
  19     "h2",
  20     "h3",
  21     "h4",
  22     "h5",
  23     "h6",
  24     "hr",
  25     "i",
  26     "li",
  27     "ol",
  28     "p",
  29     "pre",
  30     "span",
  31     "strong",
  32     "table",
  33     "tbody",
  34     "td",
  35     "th",
  36     "thead",
  37     "tr",
  38     "ul",
  39 ]
  40 
  41 
  42 ALLOWED_ATTRIBUTES = {
  43     "a": ["href", "title", "class"],
  44     "abbr": ["title"],
  45     "acronym": ["title"],
  46     "table": ["width"],
  47     "td": ["width", "align"],
  48     "div": ["class"],
  49     "p": ["class"],
  50     "span": ["class", "title"],
  51 }
  52 
  53 ALLOWED_PROTOCOLS = ["http", "https", "mailto", "tel"]
  54 
  55 
  56 def markdown_compile(source):
  57     extensions = ["markdown.extensions.sane_lists", "markdown.extensions.nl2br"]
  58     return bleach.clean(
  59         markdown.markdown(source, extensions=extensions),
  60         tags=ALLOWED_TAGS,
  61         attributes=ALLOWED_ATTRIBUTES,
  62         protocols=ALLOWED_PROTOCOLS,
  63     )
  64 
  65 
  66 @register.filter
  67 def rich_text(text: str, **kwargs):
  68     """
  69     Processes markdown and cleans HTML in a text input.
  70     """
  71     text = str(text)
  72     linker = bleach.Linker(parse_email=True)
  73     body_md = linker.linkify(markdown_compile(text))
  74     return mark_safe(body_md)
  75
  [end of ephios/extra/templatetags/rich_text.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/ephios/extra/templatetags/rich_text.py b/ephios/extra/templatetags/rich_text.py
  --- a/ephios/extra/templatetags/rich_text.py
  +++ b/ephios/extra/templatetags/rich_text.py
  @@ -53,22 +53,28 @@
   ALLOWED_PROTOCOLS = ["http", "https", "mailto", "tel"]
   
   
  -def markdown_compile(source):
  +def markdown_compile(source, excluded_tags=""):
       extensions = ["markdown.extensions.sane_lists", "markdown.extensions.nl2br"]
  +    tags = ALLOWED_TAGS.copy()
  +    for tag in excluded_tags.split(","):
  +        try:
  +            tags.remove(tag)
  +        except ValueError:
  +            pass
       return bleach.clean(
           markdown.markdown(source, extensions=extensions),
  -        tags=ALLOWED_TAGS,
  +        tags=tags,
           attributes=ALLOWED_ATTRIBUTES,
           protocols=ALLOWED_PROTOCOLS,
       )
   
   
   @register.filter
  -def rich_text(text: str, **kwargs):
  +def rich_text(text: str, excluded_tags=""):
       """
       Processes markdown and cleans HTML in a text input.
       """
       text = str(text)
       linker = bleach.Linker(parse_email=True)
  -    body_md = linker.linkify(markdown_compile(text))
  +    body_md = linker.linkify(markdown_compile(text, excluded_tags=excluded_tags))
       return mark_safe(body_md)
  
verification_info: {"golden_diff": "diff --git a/ephios/extra/templatetags/rich_text.py b/ephios/extra/templatetags/rich_text.py\n--- a/ephios/extra/templatetags/rich_text.py\n+++ b/ephios/extra/templatetags/rich_text.py\n@@ -53,22 +53,28 @@\n ALLOWED_PROTOCOLS = [\"http\", \"https\", \"mailto\", \"tel\"]\n \n \n-def markdown_compile(source):\n+def markdown_compile(source, excluded_tags=\"\"):\n     extensions = [\"markdown.extensions.sane_lists\", \"markdown.extensions.nl2br\"]\n+    tags = ALLOWED_TAGS.copy()\n+    for tag in excluded_tags.split(\",\"):\n+        try:\n+            tags.remove(tag)\n+        except ValueError:\n+            pass\n     return bleach.clean(\n         markdown.markdown(source, extensions=extensions),\n-        tags=ALLOWED_TAGS,\n+        tags=tags,\n         attributes=ALLOWED_ATTRIBUTES,\n         protocols=ALLOWED_PROTOCOLS,\n     )\n \n \n @register.filter\n-def rich_text(text: str, **kwargs):\n+def rich_text(text: str, excluded_tags=\"\"):\n     \"\"\"\n     Processes markdown and cleans HTML in a text input.\n     \"\"\"\n     text = str(text)\n     linker = bleach.Linker(parse_email=True)\n-    body_md = linker.linkify(markdown_compile(text))\n+    body_md = linker.linkify(markdown_compile(text, excluded_tags=excluded_tags))\n     return mark_safe(body_md)\n", "issue": "Format event description\nAs a planner, I want to be able to format the event description. This should at least mean that links will be formatted so that they are clickable. Maybe this should mean that the description will accept Markdown.\n", "before_files": [{"content": "import bleach\nimport markdown\nfrom django import template\nfrom django.utils.safestring import mark_safe\n\nregister = template.Library()\n\nALLOWED_TAGS = [\n    \"a\",\n    \"abbr\",\n    \"acronym\",\n    \"b\",\n    \"blockquote\",\n    \"br\",\n    \"code\",\n    \"div\",\n    \"em\",\n    \"h1\",\n    \"h2\",\n    \"h3\",\n    \"h4\",\n    \"h5\",\n    \"h6\",\n    \"hr\",\n    \"i\",\n    \"li\",\n    \"ol\",\n    \"p\",\n    \"pre\",\n    \"span\",\n    \"strong\",\n    \"table\",\n    \"tbody\",\n    \"td\",\n    \"th\",\n    \"thead\",\n    \"tr\",\n    \"ul\",\n]\n\n\nALLOWED_ATTRIBUTES = {\n    \"a\": [\"href\", \"title\", \"class\"],\n    \"abbr\": [\"title\"],\n    \"acronym\": [\"title\"],\n    \"table\": [\"width\"],\n    \"td\": [\"width\", \"align\"],\n    \"div\": [\"class\"],\n    \"p\": [\"class\"],\n    \"span\": [\"class\", \"title\"],\n}\n\nALLOWED_PROTOCOLS = [\"http\", \"https\", \"mailto\", \"tel\"]\n\n\ndef markdown_compile(source):\n    extensions = [\"markdown.extensions.sane_lists\", \"markdown.extensions.nl2br\"]\n    return bleach.clean(\n        markdown.markdown(source, extensions=extensions),\n        tags=ALLOWED_TAGS,\n        attributes=ALLOWED_ATTRIBUTES,\n        protocols=ALLOWED_PROTOCOLS,\n    )\n\n\n@register.filter\ndef rich_text(text: str, **kwargs):\n    \"\"\"\n    Processes markdown and cleans HTML in a text input.\n    \"\"\"\n    text = str(text)\n    linker = bleach.Linker(parse_email=True)\n    body_md = linker.linkify(markdown_compile(text))\n    return mark_safe(body_md)\n", "path": "ephios/extra/templatetags/rich_text.py"}]}