Classes
FenceClassifierMixin
8
▼
Mixin providing fenced code block classification.
FenceClassifierMixin
8
▼
Mixin providing fenced code block classification.
Attributes
| Name | Type | Description |
|---|---|---|
_fence_char |
str
|
— |
_fence_count |
int
|
— |
_fence_info |
str
|
— |
_fence_indent |
int
|
— |
_mode |
LexerMode
|
— |
Methods
Internal Methods 3 ▼
_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
_try_classify_fence_start
4
Token | None
▼
Try to classify content as fenced code start.
Fenced code blocks start with 3+…
_try_classify_fence_start
4
Token | None
▼
def _try_classify_fence_start(self, content: str, line_start: int, indent: int = 0, *, change_mode: bool = True) -> Token | None
Try to classify content as fenced code start.
Fenced code blocks start with 3+ backticks or tildes. Backtick fences cannot have backticks in the info string.
Parameters
| Name | Type | Description |
|---|---|---|
content |
— |
Line content with leading whitespace stripped |
line_start |
— |
Position in source where line starts |
indent |
— |
Number of leading spaces (for CommonMark indent stripping) Default:0
|
change_mode |
— |
If True, switch lexer to CODE_FENCE mode. Set to False when detecting fences inside containers (blockquotes) where the container handles fence content collection. Default:True
|
Returns
Token | None
Token if valid fence, None otherwise.
_is_closing_fence
1
bool
▼
Check if line is a closing fence for current code block.
CommonMark 4.5: Closi…
_is_closing_fence
1
bool
▼
def _is_closing_fence(self, line: str) -> bool
Check if line is a closing fence for current code block.
CommonMark 4.5: Closing fences may be indented 0-3 spaces. If indented 4+ spaces, it's NOT a closing fence (it's code content).
Parameters
| Name | Type | Description |
|---|---|---|
line |
— |
Full line content including leading whitespace |
Returns
bool
True if this is a valid closing fence.