Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,5 @@ __pycache__/
.DS_Store

docs/api/

uv.lock
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repos:
rev: v1.13.0
hooks:
- id: mypy
additional_dependencies: [mdurl]
additional_dependencies: [mdurl, typing-extensions]
exclude: >
(?x)^(
benchmarking/.*\.py|
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"EnvType",
"Path",
"Ellipsis",
"NotRequired",
)
]

Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ All functions and class methods should be annotated with types and include a doc

## Testing

For code tests, markdown-it-py uses [pytest](https://docs.pytest.org)):
For code tests, markdown-it-py uses [pytest](https://docs.pytest.org):

```shell
>> cd markdown-it-py
Expand Down
11 changes: 10 additions & 1 deletion markdown_it/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from collections.abc import Iterable, MutableMapping
from collections.abc import MutableMapping as MutableMappingABC
from pathlib import Path
from typing import Any, Callable, TypedDict, cast
from typing import TYPE_CHECKING, Any, Callable, TypedDict, cast

if TYPE_CHECKING:
from typing_extensions import NotRequired

Check warning on line 9 in markdown_it/utils.py

View check run for this annotation

Codecov / codecov/patch

markdown_it/utils.py#L9

Added line #L9 was not covered by tests


EnvType = MutableMapping[str, Any] # note: could use TypeAlias in python 3.10
"""Type for the environment sandbox used in parsing and rendering,
Expand Down Expand Up @@ -32,6 +36,11 @@
"""CSS language prefix for fenced blocks."""
highlight: Callable[[str, str, str], str] | None
"""Highlighter function: (content, lang, attrs) -> str."""
store_labels: NotRequired[bool]
"""Store link label in link/image token's metadata (under Token.meta['label']).

This is a Python only option, and is intended for the use of round-trip parsing.
"""


class PresetType(TypedDict):
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ benchmarking = [
]
profiling = ["gprof2dot"]

[dependency-groups]
mypy = ["mypy", "mdurl", "typing-extensions"]

[project.scripts]
markdown-it = "markdown_it.cli.parse:main"

Expand Down Expand Up @@ -106,7 +109,7 @@ module = ["tests.test_plugins.*", "markdown.*"]
ignore_errors = true

[[tool.mypy.overrides]]
module = ["markdown.*"]
module = ["markdown.*", "linkify_it.*"]
ignore_missing_imports = true

[tool.pytest.ini_options]
Expand Down