# autolinks

URL: /patitas/api/plugins/autolinks/
Section: plugins
Description: Autolinks plugin for Patitas.

Enables GFM **extended** autolinks: bare URLs, ``www.`` links, and bare email
addresses are turned into links inside ordinary inline text. This implements
the GFM "Autolinks (extension)" rules:
https://github.github.com/gfm/#autolinks-extension-

    >>> from patitas import Markdown
    >>> Markdown(plugins=["autolinks"])("Visit https://example.com now")
    '<p>Visit <a href="https://example.com">https://example.com</a> now</p>\n'
    >>> Markdown(plugins=["autolinks"])("See www.example.com")
    '<p>See <a href="http://www.example.com">www.example.com</a></p>\n'
    >>> Markdown(plugins=["autolinks"])("Mail foo@example.com")
    '<p>Mail <a href="mailto:foo@example.com">foo@example.com</a></p>\n'

Recognized forms (only when this plugin is enabled):
- bare URLs:   ``http://example.com``, ``https://example.com``
- www links:   ``www.example.com`` (rendered href gets ``http://`` prepended;
               the link text keeps the original ``www.`` text)
- bare emails: ``user@example.com`` (href ``mailto:...``)

Rules applied (per the GFM extension):
- An autolink is recognized only at a *left boundary*: start-of-line/text,
  after whitespace, or after one of ``* _ ~ (``.
- A URL/``www.`` body runs until whitespace or ``<``, so characters that are
  otherwise inline-special (``& ~ $ _ * [ ! {``) are kept as part of the link.
  This means real-world URLs with query separators (``?a=1&b=2``), ``~user``
  paths, and ``Foo_(bar)`` slugs link in full.
- Trailing punctuation (``? ! . , : * _ ~``) is excluded from the link. A
  trailing ``)`` is excluded when there are more ``)`` than ``(`` in the match.
  A trailing entity reference (``&...;``) is stripped.
- The authority must contain at least one ``.`` and no spaces.

CommonMark **angle-bracket** autolinks work without this plugin:

    >>> Markdown()("Visit <https://example.com>")
    '<p>Visit <a href="https://example.com">https://example.com</a></p>\n'

Precedence (GFM: code spans > autolinks > emphasis):
- A backtick ends a URL body so a code span keeps its higher CommonMark/GFM
  precedence (``http://a.com`code` `` does not swallow the code span).
- An ``_`` inside an email *local part* is recognized as part of the address
  before emphasis tokenization, so e.g. ``a_b@example.com`` links in full. (``*``
  and ``~`` are not valid email-local-part characters, so only ``_`` matters.)

Thread Safety:
This plugin is stateless and thread-safe.

---

> For a complete page index, fetch /patitas/llms.txt.

Open LLM text
(/patitas/api/plugins/autolinks/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fplugins%2Fautolinks%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fplugins%2Fautolinks%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fplugins%2Fautolinks%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fplugins%2Fautolinks%2Findex.txt)

Module

#
`plugins.autolinks`

Autolinks plugin for Patitas.

Enables GFM extended autolinks: bare URLs,`www.`links, and bare email
addresses are turned into links inside ordinary inline text. This implements
the GFM "Autolinks (extension)" rules:
https://github.github.com/gfm/#autolinks-extension-

```
>>> from patitas import Markdown
>>> Markdown(plugins=["autolinks"])("Visit https://example.com now")
'<p>Visit <a href="https://example.com">https://example.com</a> now</p>\n'
>>> Markdown(plugins=["autolinks"])("See www.example.com")
'<p>See <a href="http://www.example.com">www.example.com</a></p>\n'
>>> Markdown(plugins=["autolinks"])("Mail foo@example.com")
'<p>Mail <a href="mailto:foo@example.com">foo@example.com</a></p>\n'
```

Recognized forms (only when this plugin is enabled):

- bare URLs:`http://example.com`, `https://example.com`

- www links:`www.example.com` (rendered href gets `http://`prepended;

```
the link text keeps the original ``www.`` text)
```

- bare emails:`user@example.com` (href `mailto:...`)

Rules applied (per the GFM extension):

- An autolink is recognized only at a left boundary: start-of-line/text,
after whitespace, or after one of`* _ ~ (`.

- A URL/`www.` body runs until whitespace or `<`, so characters that are
otherwise inline-special (`& ~ $ _ * [ ! {`) are kept as part of the link.
This means real-world URLs with query separators (`?a=1&b=2`), `~user`
paths, and`Foo_(bar)`slugs link in full.

- Trailing punctuation (`? ! . , : * _ ~`) is excluded from the link. A
trailing`)` is excluded when there are more `)` than `(`in the match.
A trailing entity reference (`&...;`) is stripped.

- The authority must contain at least one`.`and no spaces.

CommonMark angle-bracket autolinks work without this plugin:

```
>>> Markdown()("Visit <https://example.com>")
'<p>Visit <a href="https://example.com">https://example.com</a></p>\n'
```

Precedence (GFM: code spans > autolinks > emphasis):

- A backtick ends a URL body so a code span keeps its higher CommonMark/GFM
precedence (`http://a.com`code` `does not swallow the code span).

- An`_`inside an email local part is recognized as part of the address
before emphasis tokenization, so e.g.`a_b@example.com` links in full. (`*`
and`~` are not valid email-local-part characters, so only `_`matters.)

Thread Safety:

This plugin is stateless and thread-safe.

1Class

## Classes

`AutolinksPlugin`

1

▼

Plugin enabling automatic (GFM extended) URL and email linking.

Enabling via ``Markdown(plugins=["…

Plugin enabling automatic (GFM extended) URL and email linking.

Enabling via`Markdown(plugins=["autolinks"])`sets
`ParseConfig.autolinks_enabled` (/patitas/api/config/#ParseConfig), which the inline tokenizer consults to
scan plain-text runs for bare URLs,`www.`links, and emails. CommonMark
angle-bracket autolinks`<https://...>`already work without this plugin.

#### Methods

`name`

0

`str`

▼

property

`def name(self) -> str`

##### Returns

`str`
