Classes
LinkRefClassifierMixin
12
▼
Mixin providing link reference definition classification.
LinkRefClassifierMixin
12
▼
Mixin providing link reference definition classification.
Attributes
| Name | Type | Description |
|---|---|---|
_source |
str
|
— |
_source_len |
int
|
— |
_pos |
int
|
— |
_lineno |
int
|
— |
_col |
int
|
— |
Methods
Internal Methods 7 ▼
_make_token
6
Token
▼
Create token with raw coordinates. Implemented by Lexer.
_make_token
6
Token
▼
def _make_token(self, token_type: TokenType, value: str, start_pos: int, *, start_col: int | None = None, end_pos: int | None = None, line_indent: int = -1) -> Token
Parameters
| Name | Type | Description |
|---|---|---|
token_type |
— |
|
value |
— |
|
start_pos |
— |
|
start_col |
— |
Default:None
|
end_pos |
— |
Default:None
|
line_indent |
— |
Default:-1
|
Returns
Token
_find_line_end
0
int
▼
Find end of current line. Implemented by Lexer.
_find_line_end
0
int
▼
def _find_line_end(self) -> int
Returns
int
_commit_to
1
▼
Commit position. Implemented by Lexer.
_commit_to
1
▼
def _commit_to(self, line_end: int) -> None
Parameters
| Name | Type | Description |
|---|---|---|
line_end |
— |
_try_classify_link_reference_def
3
Token | None
▼
Try to classify content as link reference definition.
CommonMark 4.7:
**A lin…
_try_classify_link_reference_def
3
Token | None
▼
def _try_classify_link_reference_def(self, first_line_content: str, line_start: int, indent: int = 0) -> Token | None
Try to classify content as link reference definition.
CommonMark 4.7:
A link reference definition consists of:
- A link label (indented by up to 3 spaces)
- A colon (:)
- Optional whitespace (including up to one line change)
- A link destination
- Optional whitespace (including up to one line change)
- An optional link title
Parameters
| Name | Type | Description |
|---|---|---|
first_line_content |
— |
Content of the first line (indents < 4 stripped) |
line_start |
— |
Source position where the first line starts |
indent |
— |
Number of leading spaces (for line_indent) Default:0
|
Returns
Token | None
LINK_REFERENCE_DEF token if valid, None otherwise.
Token value format: label|url|title (pipe-separated)
_parse_label_multiline
2
tuple[str, int, bool]
▼
Parse link label, possibly spanning multiple lines.
_parse_label_multiline
2
tuple[str, int, bool]
▼
def _parse_label_multiline(self, first_line: str, line_start: int) -> tuple[str, int, bool]
Parameters
| Name | Type | Description |
|---|---|---|
first_line |
— |
|
line_start |
— |
Returns
tuple[str, int, bool]
_parse_destination_multiline
1
tuple[str, int, bool]
▼
Parse link destination, possibly after one newline.
_parse_destination_multiline
1
tuple[str, int, bool]
▼
def _parse_destination_multiline(self, start_pos: int) -> tuple[str, int, bool]
Parameters
| Name | Type | Description |
|---|---|---|
start_pos |
— |
Returns
tuple[str, int, bool]
_parse_title_multiline
1
tuple[str, int, bool]
▼
Parse optional link title, possibly after one newline.
_parse_title_multiline
1
tuple[str, int, bool]
▼
def _parse_title_multiline(self, start_pos: int) -> tuple[str, int, bool]
Parameters
| Name | Type | Description |
|---|---|---|
start_pos |
— |
Returns
tuple[str, int, bool]