We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `liberapay/utils/markdown.py`
Content:
```
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 FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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

{"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"}], "after_files": [{"content": "from __future__ import absolute_import, division, print_function, unicode_literals\n\nimport re\n\nfrom markupsafe import Markup, escape\nimport misaka as m  # http://misaka.61924.nl/\n\n\nurl_re = re.compile(r'^(https?|xmpp):')\n\n\nclass 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\nrenderer = CustomRenderer(flags=m.HTML_SKIP_HTML)\nmd = m.Markdown(renderer, extensions=('autolink', 'strikethrough', 'no-intra-emphasis'))\n\n\ndef render(markdown):\n    return Markup(md(markdown))\n", "path": "liberapay/utils/markdown.py"}]}