prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  add support for xmpp: uri in markdown syntax
  When adding and XMPP uri in the following form:
  `[sat@chat.jabberfr.org](xmpp:sat@chat.jabberfr.org?join)`
  the uri syntax is shown raw instead of linking to the room as expected.
  add support for xmpp: uri in markdown syntax
  When adding and XMPP uri in the following form:
  `[sat@chat.jabberfr.org](xmpp:sat@chat.jabberfr.org?join)`
  the uri syntax is shown raw instead of linking to the room as expected.
  
  </issue>
  <code>
  [start of liberapay/utils/markdown.py]
  1 from markupsafe import Markup
  2 import misaka as m  # http://misaka.61924.nl/
  3 
  4 def render(markdown):
  5     return Markup(m.html(
  6         markdown,
  7         extensions=m.EXT_AUTOLINK | m.EXT_STRIKETHROUGH | m.EXT_NO_INTRA_EMPHASIS,
  8         render_flags=m.HTML_SKIP_HTML | m.HTML_TOC | m.HTML_SMARTYPANTS | m.HTML_SAFELINK
  9     ))
  10
  [end of liberapay/utils/markdown.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/liberapay/utils/markdown.py b/liberapay/utils/markdown.py
  --- a/liberapay/utils/markdown.py
  +++ b/liberapay/utils/markdown.py
  @@ -1,9 +1,41 @@
  -from markupsafe import Markup
  +from __future__ import absolute_import, division, print_function, unicode_literals
  +
  +import re
  +
  +from markupsafe import Markup, escape
   import misaka as m  # http://misaka.61924.nl/
   
  +
  +url_re = re.compile(r'^(https?|xmpp):')
  +
  +
  +class CustomRenderer(m.HtmlRenderer):
  +
  +    def image(self, link, title='', alt=''):
  +        if url_re.match(link):
  +            maybe_alt = Markup(' alt="%s"') % alt if alt else ''
  +            maybe_title = Markup(' title="%s"') % title if title else ''
  +            return Markup('<img src="%s"%s%s />') % (link, maybe_alt, maybe_title)
  +        else:
  +            return escape("![%s](%s)" % (alt, link))
  +
  +    def link(self, content, link, title=''):
  +        if url_re.match(link):
  +            maybe_title = Markup(' title="%s"') % title if title else ''
  +            return Markup('<a href="%s"%s>%s</a>') % (link, maybe_title, content)
  +        else:
  +            return escape("[%s](%s)" % (content, link))
  +
  +    def autolink(self, link, is_email):
  +        if url_re.match(link):
  +            return Markup('<a href="%s">%s</a>') % (link, link)
  +        else:
  +            return escape('<%s>' % link)
  +
  +
  +renderer = CustomRenderer(flags=m.HTML_SKIP_HTML)
  +md = m.Markdown(renderer, extensions=('autolink', 'strikethrough', 'no-intra-emphasis'))
  +
  +
   def render(markdown):
  -    return Markup(m.html(
  -        markdown,
  -        extensions=m.EXT_AUTOLINK | m.EXT_STRIKETHROUGH | m.EXT_NO_INTRA_EMPHASIS,
  -        render_flags=m.HTML_SKIP_HTML | m.HTML_TOC | m.HTML_SMARTYPANTS | m.HTML_SAFELINK
  -    ))
  +    return Markup(md(markdown))
  
verification_info: {"golden_diff": "diff --git a/liberapay/utils/markdown.py b/liberapay/utils/markdown.py\n--- a/liberapay/utils/markdown.py\n+++ b/liberapay/utils/markdown.py\n@@ -1,9 +1,41 @@\n-from markupsafe import Markup\n+from __future__ import absolute_import, division, print_function, unicode_literals\n+\n+import re\n+\n+from markupsafe import Markup, escape\n import misaka as m  # http://misaka.61924.nl/\n \n+\n+url_re = re.compile(r'^(https?|xmpp):')\n+\n+\n+class CustomRenderer(m.HtmlRenderer):\n+\n+    def image(self, link, title='', alt=''):\n+        if url_re.match(link):\n+            maybe_alt = Markup(' alt=\"%s\"') % alt if alt else ''\n+            maybe_title = Markup(' title=\"%s\"') % title if title else ''\n+            return Markup('<img src=\"%s\"%s%s />') % (link, maybe_alt, maybe_title)\n+        else:\n+            return escape(\"![%s](%s)\" % (alt, link))\n+\n+    def link(self, content, link, title=''):\n+        if url_re.match(link):\n+            maybe_title = Markup(' title=\"%s\"') % title if title else ''\n+            return Markup('<a href=\"%s\"%s>%s</a>') % (link, maybe_title, content)\n+        else:\n+            return escape(\"[%s](%s)\" % (content, link))\n+\n+    def autolink(self, link, is_email):\n+        if url_re.match(link):\n+            return Markup('<a href=\"%s\">%s</a>') % (link, link)\n+        else:\n+            return escape('<%s>' % link)\n+\n+\n+renderer = CustomRenderer(flags=m.HTML_SKIP_HTML)\n+md = m.Markdown(renderer, extensions=('autolink', 'strikethrough', 'no-intra-emphasis'))\n+\n+\n def render(markdown):\n-    return Markup(m.html(\n-        markdown,\n-        extensions=m.EXT_AUTOLINK | m.EXT_STRIKETHROUGH | m.EXT_NO_INTRA_EMPHASIS,\n-        render_flags=m.HTML_SKIP_HTML | m.HTML_TOC | m.HTML_SMARTYPANTS | m.HTML_SAFELINK\n-    ))\n+    return Markup(md(markdown))\n", "issue": "add support for xmpp: uri in markdown syntax\nWhen adding and XMPP uri in the following form:\r\n`[sat@chat.jabberfr.org](xmpp:sat@chat.jabberfr.org?join)`\r\nthe uri syntax is shown raw instead of linking to the room as expected.\nadd support for xmpp: uri in markdown syntax\nWhen adding and XMPP uri in the following form:\r\n`[sat@chat.jabberfr.org](xmpp:sat@chat.jabberfr.org?join)`\r\nthe uri syntax is shown raw instead of linking to the room as expected.\n", "before_files": [{"content": "from markupsafe import Markup\nimport misaka as m  # http://misaka.61924.nl/\n\ndef render(markdown):\n    return Markup(m.html(\n        markdown,\n        extensions=m.EXT_AUTOLINK | m.EXT_STRIKETHROUGH | m.EXT_NO_INTRA_EMPHASIS,\n        render_flags=m.HTML_SKIP_HTML | m.HTML_TOC | m.HTML_SMARTYPANTS | m.HTML_SAFELINK\n    ))\n", "path": "liberapay/utils/markdown.py"}]}