pymdownx_superfence_filter_lines
pymdownx_superfence_filter_lines ¤
A custom superfence for pymdown-extensions that can filters lines and plays nice with MkDocs.
Classes¤
pymdownx_superfence_filter_lines.Inputs ¤
pymdownx_superfence_filter_lines.LinesRange
dataclass
¤
A range of lines.
start and end are inclusive and the indices start from 1.
Source code in src/pymdownx_superfence_filter_lines/__init__.py
Attributes¤
end
class-attribute
instance-attribute
¤
end: int | None = None
End line.
None means the end of the file.
start
class-attribute
instance-attribute
¤
start: int | None = None
Start line.
None means the beginning of the file.
Methods:¤
__contains__ ¤
Whether the item is inside this range.
Source code in src/pymdownx_superfence_filter_lines/__init__.py
__post_init__ ¤
Validate inputs upon creation.
Source code in src/pymdownx_superfence_filter_lines/__init__.py
__str__ ¤
__str__() -> str
Get the string representation.
Source code in src/pymdownx_superfence_filter_lines/__init__.py
parse
classmethod
¤
Create from a string.
The string can be in the following formats:
startstart:end:endstart:
where start and end are integers.
If start is empty, it is assumed to be 1.
If end is empty, it is assumed to be the end of the file.
If start appears without :, it is assumed to be both start and end.
Lines are 1-indexed.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
String to parse.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Self
|
The created range. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the string is invalid. |
Source code in src/pymdownx_superfence_filter_lines/__init__.py
pymdownx_superfence_filter_lines.LinesRanges
dataclass
¤
A set of line ranges.
Source code in src/pymdownx_superfence_filter_lines/__init__.py
Attributes¤
Methods:¤
__contains__ ¤
__post_init__ ¤
parse
classmethod
¤
parse(text: str) -> tuple[Self | None, list[ValueError]]
Create from a string.
The string must be a comma-separated list of ranges, where each range is in the
format described in
LinesRange.parse.
If no ranges are given, None is returned. If any ranges are invalid, they are
ignored and a list of errors is returned.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
String to parse.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Self | None, list[ValueError]]
|
The created ranges, or |
Source code in src/pymdownx_superfence_filter_lines/__init__.py
pymdownx_superfence_filter_lines.Options ¤
Functions:¤
pymdownx_superfence_filter_lines.do_format ¤
do_format(
src: str,
language: str,
class_name: str,
options: Options,
md: Markdown,
**kwargs: Any
) -> Any
Filter the lines and run the default highlighter.
Source code in src/pymdownx_superfence_filter_lines/__init__.py
pymdownx_superfence_filter_lines.do_validate ¤
do_validate(
language: str,
inputs: Inputs,
options: Options,
attrs: dict[str, Any],
md: Markdown,
) -> bool
Validate the inputs.