Skip to content

Commit 29f9217

Browse files
authored
[Markdown] Update to ~=3.11.2 (#16576)
1 parent cb2bd9e commit 29f9217

9 files changed

Lines changed: 126 additions & 69 deletions

File tree

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
# Deprecated types are infered as functions:
1+
# Implementation detail
2+
markdown.htmlparser.spec
3+
4+
# *args/**kwargs in implementation properly typed in stubs
5+
markdown.extensions.md_in_html.HTMLExtractorExtra.__init__
6+
markdown.htmlparser.HTMLExtractor.__init__
7+
8+
# Deprecated types are infered as functions
29
markdown.extensions.abbr.AbbrPreprocessor
310
markdown.extensions.abbr.AbbrInlineProcessor
411
markdown.postprocessors.UnescapePostprocessor

‎stubs/Markdown/METADATA.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = "~=3.10.2"
1+
version = "~=3.11.2"
22
upstream-repository = "https://github.com/Python-Markdown/markdown"

‎stubs/Markdown/markdown/core.pyi‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,39 @@ from . import (
1313
treeprocessors as _treeprocessors,
1414
)
1515
from .extensions import Extension
16+
from .inlinepatterns import DelimiterProcessor
1617
from .util import HtmlStash, Registry
1718

1819
__all__ = ["Markdown", "markdown", "markdownFromFile"]
1920

2021
logger: Logger
2122

2223
class Markdown:
24+
doc_tag: ClassVar[str]
25+
output_formats: ClassVar[dict[Literal["xhtml", "html"], Callable[[Element], str]]]
26+
27+
last_run: float
28+
tab_length: int
29+
ESCAPED_CHARS: list[str]
30+
block_level_elements: list[str]
31+
registeredExtensions: list[Extension]
32+
stripTopLevelTags: bool
33+
delimiters: DelimiterProcessor | None
34+
35+
# Set by build_parser().
2336
preprocessors: Registry[_preprocessors.Preprocessor]
37+
parser: blockparser.BlockParser
2438
inlinePatterns: Registry[inlinepatterns.Pattern]
2539
treeprocessors: Registry[_treeprocessors.Treeprocessor]
2640
postprocessors: Registry[_postprocessors.Postprocessor]
27-
parser: blockparser.BlockParser
41+
42+
references: dict[str, tuple[str, str]]
2843
htmlStash: HtmlStash
29-
output_formats: ClassVar[dict[Literal["xhtml", "html"], Callable[[Element], str]]]
44+
45+
# Set by set_output_format().
3046
output_format: Literal["xhtml", "html"]
3147
serializer: Callable[[Element], str]
32-
tab_length: int
33-
block_level_elements: list[str]
34-
registeredExtensions: list[Extension]
35-
ESCAPED_CHARS: list[str]
36-
doc_tag: ClassVar[str]
37-
stripTopLevelTags: bool
48+
3849
def __init__(
3950
self,
4051
*,

‎stubs/Markdown/markdown/extensions/__init__.pyi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ from typing import Any
33

44
from markdown.core import Markdown
55

6+
# The allowed value types depend on the respective keys.
67
class Extension:
78
config: Mapping[str, list[Any]]
89
def __init__(self, **kwargs: Any) -> None: ...

‎stubs/Markdown/markdown/extensions/attr_list.pyi‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from re import Pattern
2+
from typing import Final
23
from xml.etree.ElementTree import Element
34

45
from markdown.extensions import Extension
@@ -8,12 +9,17 @@ def get_attrs_and_remainder(attrs_string: str) -> tuple[list[tuple[str, str]], s
89
def get_attrs(str: str) -> list[tuple[str, str]]: ...
910
def isheader(elem: Element) -> bool: ...
1011

12+
NAME_RE: Final[Pattern[str]]
13+
14+
def sanitize_name(name: str) -> str: ...
15+
1116
class AttrListTreeprocessor(Treeprocessor):
12-
BASE_RE: str
13-
HEADER_RE: Pattern[str]
14-
BLOCK_RE: Pattern[str]
15-
INLINE_RE: Pattern[str]
16-
NAME_RE: Pattern[str]
17+
BASE_RE: Final[str]
18+
HEADER_RE: Final[Pattern[str]]
19+
BLOCK_RE: Final[Pattern[str]]
20+
INLINE_RE: Final[Pattern[str]]
21+
NAME_RE: Final[Pattern[str]]
22+
1723
def run(self, doc: Element) -> None: ...
1824
def assign_attrs(self, elem: Element, attrs_string: str, *, strict: bool = False) -> str: ...
1925
def sanitize_name(self, name: str) -> str: ...
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
from markdown.extensions import Extension
2-
from markdown.inlinepatterns import UnderscoreProcessor
1+
from typing import Any
32

4-
EMPHASIS_RE: str
5-
STRONG_RE: str
6-
STRONG_EM_RE: str
3+
from markdown.extensions import Extension
74

8-
class LegacyUnderscoreProcessor(UnderscoreProcessor): ...
95
class LegacyEmExtension(Extension): ...
106

11-
def makeExtension(**kwargs) -> LegacyEmExtension: ...
7+
# kwargs are config key/value pairs, where the value type depends on the key.
8+
def makeExtension(**kwargs: Any) -> LegacyEmExtension: ...

‎stubs/Markdown/markdown/extensions/md_in_html.pyi‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from collections.abc import Iterable, Mapping
22
from typing import Literal
3-
from xml.etree.ElementTree import Element, TreeBuilder
3+
from xml.etree.ElementTree import Element
44

55
from markdown.blockprocessors import BlockProcessor
66
from markdown.extensions import Extension
@@ -9,15 +9,15 @@ from markdown.postprocessors import RawHtmlPostprocessor
99
from markdown.preprocessors import Preprocessor
1010

1111
class HTMLExtractorExtra(HTMLExtractor):
12-
block_level_tags: set[str]
1312
span_tags: set[str]
1413
raw_tags: set[str]
15-
block_tags: set[str]
16-
span_and_blocks_tags: set[str]
17-
mdstack: list[str]
18-
treebuilder: TreeBuilder
19-
mdstate: list[Literal["block", "span", "off"] | None]
20-
mdstarted: list[bool]
14+
15+
@property
16+
def block_level_tags(self) -> set[str]: ...
17+
@property
18+
def block_tags(self) -> set[str]: ...
19+
@property
20+
def span_and_blocks_tags(self) -> set[str]: ...
2121
def get_element(self) -> Element: ...
2222
def get_state(self, tag: str, attrs: Mapping[str, str]) -> Literal["block", "span", "off"] | None: ...
2323
def handle_starttag(self, tag: str, attrs: Iterable[tuple[str, str | None]]) -> None: ...
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
11
import html.parser as htmlparser
22
import re
3-
from _frozen_importlib import ModuleSpec
43
from collections.abc import Sequence
4+
from typing import Final
55

66
from markdown import Markdown
77

8-
spec: ModuleSpec
9-
commentclose: re.Pattern[str]
10-
blank_line_re: re.Pattern[str]
8+
commentclose: Final[re.Pattern[str]]
9+
blank_line_re: Final[re.Pattern[str]]
10+
inner_blank_line_re: Final[re.Pattern[str]]
11+
void_tags: Final[frozenset[str]]
1112

1213
class HTMLExtractor(htmlparser.HTMLParser):
1314
empty_tags: set[str]
1415
lineno_start_cache: list[int]
1516
md: Markdown
16-
def __init__(self, md: Markdown, *args, **kwargs): ...
17+
18+
# Set by reset().
1719
inraw: bool
1820
intail: bool
1921
stack: list[str]
22+
inline_stack: list[str]
2023
cleandoc: list[str]
24+
25+
def __init__(self, md: Markdown, *, convert_charrefs=False, scripting=False) -> None: ...
2126
@property
2227
def line_offset(self) -> int: ...
2328
def at_line_start(self) -> bool: ...
2429
def get_endtag_text(self, tag: str) -> str: ...
2530
def handle_starttag(self, tag: str, attrs: Sequence[tuple[str, str]]) -> None: ... # type: ignore[override]
31+
def open_inline_tag(self, tag: str) -> None: ...
32+
def close_inline_tag(self, tag: str) -> None: ...
33+
def inline_close_follows(self, text: str) -> bool: ...
2634
def handle_empty_tag(self, data: str, is_block: bool) -> None: ...
2735
def handle_decl(self, data: str) -> None: ...
36+
def unknown_decl(self, data: str) -> None: ...
2837
def parse_bogus_comment(self, i: int, report: int = 0) -> int: ...
2938
def get_starttag_text(self) -> str: ...

‎stubs/Markdown/markdown/inlinepatterns.pyi‎

Lines changed: 60 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,27 @@
11
import re
2+
from _typeshed import Unused
3+
from collections import deque
24
from collections.abc import Collection
3-
from typing import ClassVar, NamedTuple
5+
from typing import ClassVar, Final, NamedTuple
46
from xml.etree.ElementTree import Element
57

68
from markdown import util
79
from markdown.core import Markdown
810

9-
def build_inlinepatterns(md: Markdown, **kwargs) -> util.Registry[Pattern]: ...
10-
11-
NOIMG: str
12-
BACKTICK_RE: str
13-
ESCAPE_RE: str
14-
EMPHASIS_RE: str
15-
STRONG_RE: str
16-
SMART_STRONG_RE: str
17-
SMART_EMPHASIS_RE: str
18-
SMART_STRONG_EM_RE: str
19-
EM_STRONG_RE: str
20-
EM_STRONG2_RE: str
21-
STRONG_EM_RE: str
22-
STRONG_EM2_RE: str
23-
STRONG_EM3_RE: str
24-
LINK_RE: str
25-
IMAGE_LINK_RE: str
26-
REFERENCE_RE: str
27-
IMAGE_REFERENCE_RE: str
28-
NOT_STRONG_RE: str
29-
AUTOLINK_RE: str
30-
AUTOMAIL_RE: str
31-
HTML_RE: str
32-
ENTITY_RE: str
33-
LINE_BREAK_RE: str
11+
def build_inlinepatterns(md: Markdown, **kwargs: Unused) -> util.Registry[Pattern]: ...
12+
13+
NOIMG: Final[str]
14+
BACKTICK_RE: Final[str]
15+
ESCAPE_RE: Final[str]
16+
LINK_RE: Final[str]
17+
IMAGE_LINK_RE: Final[str]
18+
REFERENCE_RE: Final[str]
19+
IMAGE_REFERENCE_RE: Final[str]
20+
AUTOLINK_RE: Final[str]
21+
AUTOMAIL_RE: Final[str]
22+
HTML_RE: Final[str]
23+
ENTITY_RE: Final[str]
24+
LINE_BREAK_RE: Final[str]
3425

3526
def dequote(string: str) -> str: ...
3627

@@ -74,6 +65,8 @@ class BacktickInlineProcessor(InlineProcessor):
7465
ESCAPED_BSLASH: str
7566
tag: str
7667
def __init__(self, pattern: str) -> None: ...
68+
def find_code_spans(self, start: int, text: str) -> tuple[int, int] | None: ...
69+
def handleMatch(self, m: re.Match[str], data: str) -> tuple[Element | str | None, int | None, int | None]: ... # type: ignore[override]
7770

7871
class DoubleTagPattern(SimpleTagPattern): ...
7972
class DoubleTagInlineProcessor(SimpleTagInlineProcessor): ...
@@ -82,15 +75,48 @@ class HtmlInlineProcessor(InlineProcessor):
8275
def unescape(self, text: str) -> str: ...
8376
def backslash_unescape(self, text: str) -> str: ...
8477

85-
class AsteriskProcessor(InlineProcessor):
86-
PATTERNS: ClassVar[list[EmStrongItem]]
87-
def build_single(self, m: re.Match[str], tag: str, idx: int) -> Element: ...
88-
def build_double(self, m: re.Match[str], tags: str, idx: int) -> Element: ...
89-
def build_double2(self, m: re.Match[str], tags: str, idx: int) -> Element: ...
90-
def parse_sub_patterns(self, data: str, parent: Element, last: Element | None, idx: int) -> None: ...
91-
def build_element(self, m: re.Match[str], builder: str, tags: str, index: int) -> Element: ...
78+
class Delimiter:
79+
stack: deque[tuple[int, int, bool, int]]
80+
tag_count: int
81+
tags: tuple[str, str]
82+
double: bool
83+
single: bool
84+
smart: bool
85+
86+
token: str
87+
max_size: int
88+
boundary: re.Pattern[str]
89+
bad: re.Pattern[str]
90+
91+
def __init__(self, token: str, tags: str, smart: bool, double: bool): ...
92+
def reset(self) -> None: ...
93+
94+
class DelimiterProcessor(InlineProcessor):
95+
SPACE: Final[re.Pattern[str]]
96+
97+
regions: list[tuple[int, int, int, int, tuple[str, str], int]]
98+
stack: list[tuple[int, int, bool, int]]
99+
tokens: list[str]
100+
delimiters: dict[str, Delimiter]
101+
cache_index: int
102+
cache_pos: int
103+
md: Markdown
104+
safe_mode: bool
105+
pattern: str
106+
compiled_re: re.Pattern[str]
92107

93-
class UnderscoreProcessor(AsteriskProcessor): ...
108+
def __init__(self, token: str, tags: str, md: Markdown, smart: bool = False, double: bool = False) -> None: ...
109+
def add(self, token: str, tags: str, smart: bool = False, double: bool = False) -> None: ...
110+
def remove(self, token: str) -> None: ...
111+
def reset(self) -> None: ...
112+
def increment_next_position(self, start: int, count: int) -> None: ...
113+
def get_cached_result(self, pos: int, data: str) -> tuple[Element, int, int]: ...
114+
def get_match(self, data: str, start: int) -> re.Match[str] | None: ...
115+
def search(self, data: str, start: int) -> re.Match[str] | None: ...
116+
def add_region(self, delim: Delimiter, a: int, b: int, c: int, d: int, size: int) -> None: ...
117+
def handleMatch( # type: ignore[override]
118+
self, m: re.Match[str], data: str
119+
) -> tuple[Element | None, int | None, int | None]: ...
94120

95121
class LinkInlineProcessor(InlineProcessor):
96122
RE_LINK: ClassVar[re.Pattern[str]]

0 commit comments

Comments
 (0)