From 8b5adeccf6ba7257b3d3d4444f18378edd57c067 Mon Sep 17 00:00:00 2001
From: girinataraj
Date: Sat, 24 Oct 2026 15:29:55 +0530
Subject: [PATCH 1/3] Recognize additional URL schemes in automatic links
Match letter-led URL schemes instead of limiting automatic links to HTTP and FTP. Preserve the existing delimiter, destination matching, email handling, and raw HTML behavior.
Add regression tests for scheme variants, query escaping, adjacent links, code spans, and incomplete or invalid links. Document the expanded syntax.
Fixes #1244
---
docs/changelog.md | 2 +
docs/index.md | 7 +++
markdown/inlinepatterns.py | 2 +-
tests/test_syntax/inline/test_autolinks.py | 55 ++++++++++++++++++++++
4 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/docs/changelog.md b/docs/changelog.md
index 5dc7b0f8..68c920cc 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -16,6 +16,8 @@ See the [Contributing Guide](contributing.md) for details.
### Fixed
+* Recognize automatic links with URL schemes other than HTTP and FTP, such as
+ `` (#1244).
* Strip complete HTML tags with quoted `>` characters from `toc` labels and
generated heading IDs.
* Fix quadratic-time regex backtracking in `attr_list` when a block ends with an
diff --git a/docs/index.md b/docs/index.md
index 335508ff..5817555e 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -118,6 +118,13 @@ are summarized below:
foreseeable future. That said, the [Sane List Extension](extensions/sane_lists.md)
is available to provide a less surprising behavior.
+* __Automatic Links__
+
+ Automatic links recognize URL schemes followed by `://`, including schemes
+ other than HTTP and FTP, such as `` and
+ ``. URI forms without `://`, such as ``,
+ continue to be treated as raw HTML.
+
Support
-------
diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py
index ec9c7cb1..6f42bbf0 100644
--- a/markdown/inlinepatterns.py
+++ b/markdown/inlinepatterns.py
@@ -119,7 +119,7 @@ def build_inlinepatterns(md: Markdown, **kwargs: Any) -> util.Registry[InlinePro
IMAGE_REFERENCE_RE = IMAGE_LINK_RE
""" Match start of image reference (`![alt text][2]`). """
-AUTOLINK_RE = r'<((?:[Ff]|[Hh][Tt])[Tt][Pp][Ss]?://[^<>]*)>'
+AUTOLINK_RE = r'<([A-Za-z][A-Za-z0-9+.-]*://[^<>]*)>'
""" Match an automatic link (``). """
AUTOMAIL_RE = r'<([^<> !]+@[^@<> ]+)>'
diff --git a/tests/test_syntax/inline/test_autolinks.py b/tests/test_syntax/inline/test_autolinks.py
index b6bd1cf2..0c61385c 100644
--- a/tests/test_syntax/inline/test_autolinks.py
+++ b/tests/test_syntax/inline/test_autolinks.py
@@ -24,6 +24,61 @@
class TestAutomaticLinks(TestCase):
+ def test_url_schemes(self):
+ for url in (
+ 'http://example.org',
+ 'https://example.org',
+ 'ftp://example.org',
+ 'ftps://example.org',
+ 'HtTpS://example.org',
+ 'ssh://example.org',
+ 'git://example.org/repo',
+ 's3://bucket/key',
+ 'git+ssh://example.org/repo',
+ 'x.y-z://example.org',
+ ):
+ with self.subTest(url=url):
+ self.assertMarkdownRenders(
+ f'<{url}>',
+ f'{url}
'
+ )
+
+ def test_url_scheme_with_query(self):
+ self.assertMarkdownRenders(
+ '',
+ ''
+ 'ssh://example.org/path?q=one&x=two
'
+ )
+
+ def test_adjacent_url_schemes(self):
+ self.assertMarkdownRenders(
+ 'Before after',
+ 'Before ssh://one'
+ 'git://two after
'
+ )
+
+ def test_url_scheme_without_closing_bracket(self):
+ self.assertMarkdownRenders(
+ '<ssh://example.org
'
+ )
+
+ def test_url_scheme_in_code_span(self):
+ self.assertMarkdownRenders(
+ '``',
+ '<ssh://example.org>
'
+ )
+
+ def test_invalid_url_schemes(self):
+ for source, expected in (
+ ('<1http://example.org>', '<1http://example.org>
'),
+ ('', '
'),
+ ('', '
'),
+ ('boo!', 'boo!
'),
+ ):
+ with self.subTest(source=source):
+ self.assertMarkdownRenders(source, expected)
+
def test_email_address(self):
self.assertMarkdownRenders(
'asdfasdfadsfasd or you can say ',
From 013d0bab38059e5fb6f8a6f60bad66b233b825f2 Mon Sep 17 00:00:00 2001
From: girinataraj
Date: Sat, 24 Oct 2026 15:51:23 +0530
Subject: [PATCH 2/3] Cover user information in automatic links
Verify that SSH and compound-scheme URLs with user information take precedence over email matching. Classify the syntax expansion as an added feature and wrap the documentation to the project limit.
Follow up on #1244.
---
docs/changelog.md | 7 +++++--
docs/index.md | 4 ++--
tests/test_syntax/inline/test_autolinks.py | 11 +++++++++++
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/docs/changelog.md b/docs/changelog.md
index 68c920cc..0d58e6f2 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -14,10 +14,13 @@ See the [Contributing Guide](contributing.md) for details.
## [Unreleased]
-### Fixed
+### Added
-* Recognize automatic links with URL schemes other than HTTP and FTP, such as
+* Support automatic links with URL schemes other than HTTP and FTP, such as
`` (#1244).
+
+### Fixed
+
* Strip complete HTML tags with quoted `>` characters from `toc` labels and
generated heading IDs.
* Fix quadratic-time regex backtracking in `attr_list` when a block ends with an
diff --git a/docs/index.md b/docs/index.md
index 5817555e..7912d236 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -122,8 +122,8 @@ are summarized below:
Automatic links recognize URL schemes followed by `://`, including schemes
other than HTTP and FTP, such as `` and
- ``. URI forms without `://`, such as ``,
- continue to be treated as raw HTML.
+ ``. URI forms without `://`, such as
+ ``, continue to be treated as raw HTML.
Support
-------
diff --git a/tests/test_syntax/inline/test_autolinks.py b/tests/test_syntax/inline/test_autolinks.py
index 0c61385c..751ef134 100644
--- a/tests/test_syntax/inline/test_autolinks.py
+++ b/tests/test_syntax/inline/test_autolinks.py
@@ -43,6 +43,17 @@ def test_url_schemes(self):
f'{url}
'
)
+ def test_url_schemes_with_userinfo(self):
+ for url in (
+ 'ssh://user@example.org/path',
+ 'git+ssh://git@example.org/repo.git',
+ ):
+ with self.subTest(url=url):
+ self.assertMarkdownRenders(
+ f'<{url}>',
+ f'{url}
'
+ )
+
def test_url_scheme_with_query(self):
self.assertMarkdownRenders(
'',
From ecb8752b56d5cb9c4a26e5e5ec4beacc8320d45f Mon Sep 17 00:00:00 2001
From: Waylan Limberg
Date: Mon, 26 Oct 2026 15:35:23 -0400
Subject: [PATCH 3/3] Update changelog.md
---
docs/changelog.md | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/docs/changelog.md b/docs/changelog.md
index 0d58e6f2..62db54af 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -14,13 +14,10 @@ See the [Contributing Guide](contributing.md) for details.
## [Unreleased]
-### Added
+### Fixed
* Support automatic links with URL schemes other than HTTP and FTP, such as
`` (#1244).
-
-### Fixed
-
* Strip complete HTML tags with quoted `>` characters from `toc` labels and
generated heading IDs.
* Fix quadratic-time regex backtracking in `attr_list` when a block ends with an