Skip to content

Commit e53b986

Browse files
authored
Merge pull request #1094 from pre-commit/mistune3
mistune 3.x compatibility
2 parents 5bb3bab + 0f80fa6 commit e53b986

2 files changed

Lines changed: 10 additions & 17 deletions

File tree

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mako
2-
markdown-code-blocks>=3.0.0
2+
markdown-code-blocks>=3.2.0
33
markdown-to-presentation>=0.0.12
44
pre-commit>=1.21.0
55
pygments-pre-commit>=1.4.0

template_lib.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,14 @@ def _render_cmd(code: str) -> str:
9090

9191

9292
class Renderer(markdown_code_blocks.CodeRenderer):
93-
def link(
94-
self, link: str, text: str | None, title: str | None,
95-
) -> str:
96-
if link.startswith('_#'):
97-
a_id = link.removeprefix('_#')
93+
def link(self, text: str, url: str, title: str | None = None) -> str:
94+
if url.startswith('_#'):
95+
a_id = url.removeprefix('_#')
9896
return f'<a id="{a_id}" href="#{a_id}">{text}</a>'
99-
elif link.startswith('__#'):
100-
return f'<a name="{link.removeprefix("__#")}"></a>'
97+
elif url.startswith('__#'):
98+
return f'<a name="{url.removeprefix("__#")}"></a>'
10199
else:
102-
return super().link(link, text, title)
100+
return super().link(text, url, title)
103101

104102
def heading(self, text: str, level: int) -> str:
105103
match = ID_RE.search(text)
@@ -121,16 +119,11 @@ def codespan(self, text: str) -> str:
121119
else:
122120
return super().codespan(text)
123121

124-
def image(
125-
self,
126-
src: str,
127-
alt: str = '',
128-
title: str | None = None,
129-
) -> str:
122+
def image(self, text: str, url: str, title: str | None = None) -> str:
130123
return (
131124
f'<img '
132-
f' src="{html.escape(src)}"'
133-
f' alt="{html.escape(alt)}"'
125+
f' src="{html.escape(url)}"'
126+
f' alt="{html.escape(text)}"'
134127
f' class="img-fluid img-thumbnail"'
135128
f'>'
136129
)

0 commit comments

Comments
 (0)