diff --git a/pyproject.toml b/pyproject.toml index ddacbac..413984a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,9 @@ name = "mistune" description = "A sane and fast Markdown parser with useful plugins and renderers" authors = [{name = "Hsiaoming Yang", email="me@lepture.com"}] -dependencies = [] +dependencies = [ + 'typing_extensions >=4.6, <5; python_version < "3.11"' +] license = {text = "BSD-3-Clause"} dynamic = ["version"] requires-python = ">=3.7" @@ -31,6 +33,9 @@ Documentation = "https://mistune.lepture.com/" Source = "https://github.com/lepture/mistune" Donate = "https://github.com/sponsors/lepture" +[project.scripts] +mistune = "mistune.__main__:cli" + [build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta" diff --git a/src/mistune/__init__.py b/src/mistune/__init__.py index 59049d9..8f968e1 100644 --- a/src/mistune/__init__.py +++ b/src/mistune/__init__.py @@ -10,7 +10,10 @@ from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union -from typing_extensions import Literal +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal from .block_parser import BlockParser from .core import BaseRenderer, BlockState, InlineState diff --git a/src/mistune/core.py b/src/mistune/core.py index 75715fa..c14663c 100644 --- a/src/mistune/core.py +++ b/src/mistune/core.py @@ -18,7 +18,11 @@ Union, cast, ) -from typing_extensions import Self +try: + from typing import Self +except ImportError: + from typing_extensions import Self + _LINE_END = re.compile(r'\n|$') diff --git a/src/mistune/inline_parser.py b/src/mistune/inline_parser.py index e14fb6d..35b94f8 100644 --- a/src/mistune/inline_parser.py +++ b/src/mistune/inline_parser.py @@ -15,7 +15,10 @@ Union, ) -from typing_extensions import Literal +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal from .core import InlineState, Parser from .helpers import ( diff --git a/src/mistune/list_parser.py b/src/mistune/list_parser.py index 4bb2875..825f12d 100644 --- a/src/mistune/list_parser.py +++ b/src/mistune/list_parser.py @@ -3,7 +3,10 @@ import re from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Tuple, Match -from typing_extensions import Literal +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal from .util import expand_leading_tab, expand_tab, strip_end diff --git a/src/mistune/renderers/html.py b/src/mistune/renderers/html.py index f8e86d7..0147af3 100644 --- a/src/mistune/renderers/html.py +++ b/src/mistune/renderers/html.py @@ -1,6 +1,9 @@ from typing import Any, ClassVar, Dict, Optional, Tuple -from typing_extensions import Literal +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal from ..core import BaseRenderer, BlockState from ..util import escape as escape_text