# link_ref

URL: /patitas/api/lexer/classifiers/link_ref/
Section: classifiers
Description: Link reference definition classifier mixin.

Handles multi-line definitions, escaped characters, and strict validation
according to CommonMark 0.31.2 spec.

---

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

Open LLM text
(/patitas/api/lexer/classifiers/link_ref/index.txt)

Share with AI

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

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

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

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

Module

#
`lexer.classifiers.link_ref`

Link reference definition classifier mixin.

Handles multi-line definitions, escaped characters, and strict validation
according to CommonMark 0.31.2 spec.

1Class

## Classes

`LinkRefClassifierMixin`

12

▼

Mixin providing link reference definition classification.

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 (/patitas/api/tokens/#Token)`

▼

Create token with raw coordinates. Implemented by Lexer.

`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 (/patitas/api/tokens/#Token)`

`_find_line_end`

0

`int`

▼

Find end of current line. Implemented by Lexer.

`def _find_line_end(self) -> int`

##### Returns

`int`

`_commit_to`

1

▼

Commit position. Implemented by Lexer.

`def _commit_to(self, line_end: int) -> None`

##### Parameters

Name
Type
Description

`line_end`
`—`

`_try_classify_link_reference_def`

3

`Token (/patitas/api/tokens/#Token) | None`

▼

Try to classify content as link reference definition.

CommonMark 4.7:

**A lin…

`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 (/patitas/api/tokens/#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.

`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.

`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.

`def _parse_title_multiline(self, start_pos: int) -> tuple[str, int, bool]`

##### Parameters

Name
Type
Description

`start_pos`
`—`

##### Returns

`tuple[str, int, bool]`
