# plugins

URL: /patitas/api/plugins/
Section: plugins
Description: Plugin system for Patitas Markdown parser.

Plugins extend Patitas with additional syntax support:
- table: GFM-style pipe tables
- strikethrough: ~~deleted~~ syntax
- task_lists: - [ ] checkboxes (built into core, enabled by default)
- footnotes: [^1] references
- math: $inline$ and $$block$$ math
- autolinks: Automatic URL and email detection

Usage:
    >>> from patitas import Markdown
    >>>
    >>> # Enable specific plugins
    >>> md = Markdown(plugins=["table", "strikethrough", "math"])
    >>> html = md("| A | B |
|---|---|
| 1 | 2 |")
    >>>
    >>> # Enable all plugins
    >>> md = Markdown(plugins=["all"])

Plugin Architecture:
Unlike mistune's regex-based plugins, Patitas uses a state-machine lexer.
Plugins hook into specific extension points:

1. Inline plugins (strikethrough, math inline):
   - Registered with the inline parser
   - Called when special characters are encountered

2. Block plugins (table, math block, footnote definitions):
   - Registered with the block scanner
   - Called at line start when block patterns match

3. Post-processing plugins (footnotes, autolinks):
   - Transform AST or rendered output
   - Called after main parsing/rendering

Thread Safety:
All plugins are stateless. State is stored in AST nodes or passed as arguments.
Multiple threads can use the same plugin instances concurrently.

---

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

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

Share with AI

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

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

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

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

Module

#
`plugins`

Plugin system for Patitas Markdown parser.

Plugins extend Patitas with additional syntax support:

- table: GFM-style pipe tables

- strikethrough: deleted syntax

- task_lists: - [ ] checkboxes (built into core, enabled by default)

- footnotes: [^1] references

- math: $inline$ and $$block$$ math

- autolinks: Automatic URL and email detection

Usage:

```
>>> from patitas import Markdown
>>>
>>> # Enable specific plugins
>>> md = Markdown(plugins=["table", "strikethrough", "math"])
>>> html = md("| A | B |
```

|---|---|
| 1 | 2 |")
>>>
>>> # Enable all plugins
>>> md = Markdown(plugins=["all"])

Plugin Architecture:

Unlike mistune's regex-based plugins, Patitas uses a state-machine lexer.

Plugins hook into specific extension points:

-

Inline plugins (strikethrough, math inline):

- Registered with the inline parser

- Called when special characters are encountered

-

Block plugins (table, math block, footnote definitions):

- Registered with the block scanner

- Called at line start when block patterns match

-

Post-processing plugins (footnotes, autolinks):

- Transform AST or rendered output

- Called after main parsing/rendering

Thread Safety:

All plugins are stateless. State is stored in AST nodes or passed as arguments.
Multiple threads can use the same plugin instances concurrently.

1Class2Functions

## Classes

`PatitasPlugin`

1

▼

Protocol for Patitas plugins.

Plugins are lightweight markers that enable features in Patitas.
The…

Bases:

`Protocol`

Protocol for Patitas plugins.

Plugins are lightweight markers that enable features in Patitas.
The actual parsing behavior is controlled by ParseConfig via ContextVars.

To enable a plugin, pass its name to Markdown(plugins=[...]).
The Markdown class reads the plugin names and sets the appropriate
ParseConfig flags.

Thread Safety:

```
Plugins must be stateless. All state should be in AST nodes.
```

#### Methods

`name`

0

`str`

▼

Plugin identifier.

property

`def name(self) -> str`

##### Returns

`str`

## Functions

`get_plugin`

1

`PatitasPlugin (/patitas/api/plugins/#PatitasPlugin)`

▼

Get a plugin instance by name.

`def get_plugin(name: str) -> PatitasPlugin`

##### Parameters

Name
Type
Description

`name`
`str`

Plugin name (e.g., "table", "strikethrough")

##### Returns

`PatitasPlugin (/patitas/api/plugins/#PatitasPlugin)`

`apply_plugins`

4

`None`

▼

Apply plugins to parser components.

Note: This function is deprecated. Plugin …

`def apply_plugins(plugins: list[str], lexer_class: type[Lexer], parser_class: type[Parser], renderer_class: type[HtmlRenderer]) -> None`

Apply plugins to parser components.

Note: This function is deprecated. Plugin configuration is now handled
by the Markdown class via ParseConfig and ContextVars. This function
is kept for backward compatibility but no longer does anything.

##### Parameters

Name
Type
Description

`plugins`
`list[str]`

List of plugin names to apply

`lexer_class`
`type[Lexer (/patitas/api/lexer/core/#Lexer)]`

Lexer class to extend (unused)

`parser_class`
`type[Parser (/patitas/api/parser/#Parser)]`

Parser class to extend (unused)

`renderer_class`
`type[HtmlRenderer (/patitas/api/renderers/html/#HtmlRenderer)]`

Renderer class to extend (unused)
