Skip to content

Commit

Permalink
🔧 Add "store_labels" to OptionsType (#343)
Browse files Browse the repository at this point in the history
Co-authored-by: hukkin <https://github.com/hukkin>
  • Loading branch information
chrisjsewell authored Nov 30, 2024
1 parent 876c366 commit aa4e28f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
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


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 @@ class OptionsType(TypedDict):
"""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

0 comments on commit aa4e28f

Please sign in to comment.