Classes
SpecialInlineMixin
4
▼
Mixin for special inline element parsing.
Handles autolinks, HTML inline, roles ({role}`content`),…
SpecialInlineMixin
4
▼
Mixin for special inline element parsing.
Handles autolinks, HTML inline, roles (content), and math ($expression$).
Required Host Attributes: None
Required Host Methods: None
Methods
Internal Methods 4 ▼
_try_parse_autolink
3
tuple[Link, int] | None
▼
Try to parse a CommonMark autolink at position.
Autolinks are URLs or email ad…
_try_parse_autolink
3
tuple[Link, int] | None
▼
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:
Returns (Link, new_position) or None if not an autolink.
Per CommonMark 6.7:
- URI autolinks: scheme:... where scheme is [a-zA-Z][a-zA-Z0-9+.-]{1,31}
- Email autolinks: local@domain (no backslashes allowed)
Parameters
| Name | Type | Description |
|---|---|---|
text |
— |
|
pos |
— |
|
location |
— |
Returns
tuple[Link, int] | None
_try_parse_html_inline
3
tuple[HtmlInline, int] |…
▼
Try to parse inline HTML at position.
CommonMark section 6.8 defines valid raw…
_try_parse_html_inline
3
tuple[HtmlInline, int] |…
▼
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, int] | None
_try_parse_role
3
tuple[Role, int] | None
▼
Try to parse a role at position.
Syntax: {role}`content`
Returns (Role, new_p…
_try_parse_role
3
tuple[Role, int] | None
▼
def _try_parse_role(self, text: str, pos: int, location: SourceLocation) -> tuple[Role, int] | None
Try to parse a role at position.
Syntax: content
Returns (Role, new_position) or None if not a role.
Parameters
| Name | Type | Description |
|---|---|---|
text |
— |
|
pos |
— |
|
location |
— |
Returns
tuple[Role, int] | None
_try_parse_math
3
tuple[Math, int] | None
▼
Try to parse inline math at position.
Syntax: $expression$ (not $$, that's blo…
_try_parse_math
3
tuple[Math, int] | None
▼
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, int] | None
Functions
_parse_html_open_tag
2
tuple[str, int] | None
▼
Parse an HTML open tag per CommonMark spec.
CommonMark requires strict validat…
_parse_html_open_tag
2
tuple[str, int] | None
▼
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…
_percent_encode_url
1
str
▼
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