# special

URL: /patitas/api/parsing/inline/special/
Section: inline
Description: Special inline parsing for Patitas parser.

Handles HTML inline, autolinks, roles, and math expressions.

---

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

Open LLM text
(/patitas/api/parsing/inline/special/index.txt)

Share with AI

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

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

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

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

Module

#
`parsing.inline.special`

Special inline parsing for Patitas parser.

Handles HTML inline, autolinks, roles, and math expressions.

1Class2Functions

## Classes

`SpecialInlineMixin`

4

▼

Mixin for special inline element parsing.

Handles autolinks, HTML inline, roles (\{role}`content`)…

Mixin for special inline element parsing.

Handles autolinks, HTML inline, roles ({role}`content`), and math ($expression$).

Required Host Attributes: None

Required Host Methods: None

#### Methods

Internal Methods
4

▼

`_try_parse_autolink`

3

`tuple[Link (/patitas/api/nodes/#Link), int] | None`

▼

Try to parse a CommonMark autolink at position.

Autolinks are URLs or email ad…

`def _try_parse_autolink(self, text: str, pos: int, location: SourceLocation) -> tuple[Link, int] | None`

Try to parse a CommonMark autolink at position.

Autolinks are URLs or email addresses wrapped in angle brackets:

- https://example.com (https://example.com) -> ... (https://example.com)

- foo@example.com (mailto:foo@example.com) -> ... (mailto:foo@example.com)

Returns (Link, new_position) or None if not an autolink.

Per CommonMark 6.7:

- URI autolinks: scheme:... (scheme:...) where scheme is [a-zA-Z][a-zA-Z0-9+.-]{1,31}

- Email autolinks: local@domain (mailto:local@domain) (no backslashes allowed)

##### Parameters

Name
Type
Description

`text`
`—`

`pos`
`—`

`location`
`—`

##### Returns

`tuple[Link (/patitas/api/nodes/#Link), int] | None`

`_try_parse_html_inline`

3

`tuple[HtmlInline (/patitas/api/nodes/#HtmlInline), int] |…`

▼

Try to parse inline HTML at position.

CommonMark section 6.8 defines valid raw…

`def _try_parse_html_inline(self, text: str, pos: int, location: SourceLocation) -> tuple[HtmlInline, int] | None`

Try to parse inline HTML at position.

CommonMark section 6.8 defines valid raw HTML inline elements:

- Open tags:

- Closing tags:

- HTML comments:

- Processing instructions:

- Declarations:

- CDATA:

Returns (HtmlInline, new_position) or None if not valid HTML.

##### Parameters

Name
Type
Description

`text`
`—`

`pos`
`—`

`location`
`—`

##### Returns

`tuple[HtmlInline (/patitas/api/nodes/#HtmlInline), int] | None`

`_try_parse_role`

3

`tuple[Role (/patitas/api/nodes/#Role), int] | None`

▼

Try to parse a role at position.

Syntax: \{role}`content`

Returns (Role, new_…

`def _try_parse_role(self, text: str, pos: int, location: SourceLocation) -> tuple[Role, int] | None`

Try to parse a role at position.

Syntax: {role}`content`

Returns (Role, new_position) or None if not a role.

##### Parameters

Name
Type
Description

`text`
`—`

`pos`
`—`

`location`
`—`

##### Returns

`tuple[Role (/patitas/api/nodes/#Role), int] | None`

`_try_parse_math`

3

`tuple[Math (/patitas/api/nodes/#Math), int] | None`

▼

Try to parse inline math at position.

Syntax: $expression$ (not $$, that's blo…

`def _try_parse_math(self, text: str, pos: int, location: SourceLocation) -> tuple[Math, int] | None`

Try to parse inline math at position.

Syntax: $expression$ (not $$, that's block math)

Returns (Math, new_position) or None if not valid math.

##### Parameters

Name
Type
Description

`text`
`—`

`pos`
`—`

`location`
`—`

##### Returns

`tuple[Math (/patitas/api/nodes/#Math), int] | None`

## Functions

`_parse_html_open_tag`

2

`tuple[str, int] | None`

▼

Parse an HTML open tag per CommonMark spec.

CommonMark requires strict validat…

`def _parse_html_open_tag(text: str, pos: int) -> tuple[str, int] | None`

Parse an HTML open tag per CommonMark spec.

CommonMark requires strict validation:

- Tag name: ASCII letter followed by letters, digits, hyphens

- Attribute names: [a-zA-Z_:][a-zA-Z0-9_.:-]*

- Attribute values: unquoted (no spaces/quotes/=/<>/`),

```
single-quoted (no '), double-quoted (no ")
```

- Space required between tag name and first attribute

- Space required between attributes

- Optional / before final >

Returns (html_text, end_pos) or None if not valid.

##### Parameters

Name
Type
Description

`text`
`str`

`pos`
`int`

##### Returns

`tuple[str, int] | None`

`_percent_encode_url`

1

`str`

▼

Percent-encode special characters in URL for href attribute.

CommonMark requir…

`def _percent_encode_url(url: str) -> str`

Percent-encode special characters in URL for href attribute.

CommonMark requires certain characters to be percent-encoded.

##### Parameters

Name
Type
Description

`url`
`str`

##### Returns

`str`
