Skip to content

Commit 32777ab

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent dab7cb3 commit 32777ab

6 files changed

Lines changed: 30 additions & 21 deletions

File tree

‎AGENTS.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ plugin_name/
215215
Plugins create and manipulate markdown-it tokens:
216216

217217
```python
218-
token = state.push("my_type_open", "div", 1) # Opening tag
218+
token = state.push("my_type_open", "div", 1) # Opening tag
219219
token.attrSet("class", "my-class")
220220
token.markup = "..."
221221
token.map = [startLine, nextLine]
@@ -302,6 +302,7 @@ print(md.render("Some $inline$ math"))
302302
```python
303303
from markdown_it import MarkdownIt
304304

305+
305306
def my_plugin(md: MarkdownIt) -> None:
306307
md.block.ruler.before("fence", "my_rule", _my_rule)
307308
md.add_render_rule("my_type", _render_my_type)
@@ -318,6 +319,7 @@ Block rules receive `(state: StateBlock, startLine: int, endLine: int, silent: b
318319
```python
319320
from markdown_it.rules_block import StateBlock
320321

322+
321323
def my_block_rule(
322324
state: StateBlock, startLine: int, endLine: int, silent: bool
323325
) -> bool:
@@ -348,6 +350,7 @@ Inline rules receive `(state: StateInline, silent: bool) -> bool`:
348350
```python
349351
from markdown_it.rules_inline import StateInline
350352

353+
351354
def my_inline_rule(state: StateInline, silent: bool) -> bool:
352355
if state.src[state.pos] != "$":
353356
return False

‎docs/index.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ These can be enabled individually:
1111

1212
```python
1313
from markdown_it import MarkdownIt
14-
md = MarkdownIt("commonmark").enable('table')
14+
15+
md = MarkdownIt("commonmark").enable("table")
1516
```
1617

1718
or as part of a configuration:
1819

1920
```python
2021
from markdown_it import MarkdownIt
22+
2123
md = MarkdownIt("gfm-like")
2224
```
2325

@@ -33,6 +35,7 @@ They can be chained and loaded *via*:
3335
```python
3436
from markdown_it import MarkdownIt
3537
from mdit_py_plugins import plugin1, plugin2
38+
3639
md = MarkdownIt().use(plugin1, keyword=value).use(plugin2, keyword=value)
3740
html_string = md.render("some *Markdown*")
3841
```

‎mdit_py_plugins/admon/index.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def admonition(state: StateBlock, startLine: int, endLine: int, silent: bool) ->
183183
return True
184184

185185

186-
def admon_plugin(md: MarkdownIt, render: None | Callable[..., str] = None) -> None:
186+
def admon_plugin(md: MarkdownIt, render: Callable[..., str] | None = None) -> None:
187187
"""Plugin to use
188188
`python-markdown style admonitions
189189
<https://python-markdown.github.io/extensions/admonition>`_.

‎mdit_py_plugins/container/index.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def container_plugin(
2121
md: MarkdownIt,
2222
name: str,
2323
marker: str = ":",
24-
validate: None | Callable[[str, str], bool] = None,
25-
render: None | Callable[..., str] = None,
24+
validate: Callable[[str, str], bool] | None = None,
25+
render: Callable[..., str] | None = None,
2626
) -> None:
2727
"""Plugin ported from
2828
`markdown-it-container <https://github.com/markdown-it/markdown-it-container>`__.

‎mdit_py_plugins/dollarmath/index.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def dollarmath_plugin(
5454
5555
"""
5656
if label_normalizer is None:
57-
label_normalizer = lambda label: re.sub(r"\s+", "-", label) # noqa: E731
57+
label_normalizer = lambda label: re.sub(r"\s+", "-", label)
5858

5959
md.inline.ruler.before(
6060
"escape",
@@ -77,10 +77,8 @@ def dollarmath_plugin(
7777

7878
_label_renderer: Callable[[str], str]
7979
if label_renderer is None:
80-
_label_renderer = ( # noqa: E731
81-
lambda label: (
82-
f'<a href="#{label}" class="mathlabel" title="Permalink to this equation">¶</a>'
83-
)
80+
_label_renderer = lambda label: (
81+
f'<a href="#{label}" class="mathlabel" title="Permalink to this equation">¶</a>'
8482
)
8583
else:
8684
_label_renderer = label_renderer

‎mdit_py_plugins/texmath/index.py‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class RuleDictType(_RuleDictReqType, total=False):
8686

8787
def applyRule(
8888
rule: RuleDictType, string: str, begin: int, inBlockquote: bool
89-
) -> None | Match[str]:
89+
) -> Match[str] | None:
9090
if not (
9191
string.startswith(rule["tag"], begin)
9292
and (rule["pre"](string, begin) if "pre" in rule else True)
@@ -202,14 +202,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
202202
{
203203
"name": "math_block_eqno",
204204
"rex": re.compile(
205-
r"^\\\[(((?!\\\]|\\\[)[\s\S])+?)\\\]\s*?\(([^)$\r\n]+?)\)", re.M
205+
r"^\\\[(((?!\\\]|\\\[)[\s\S])+?)\\\]\s*?\(([^)$\r\n]+?)\)",
206+
re.MULTILINE,
206207
),
207208
"tmpl": '<section class="eqno"><eqn>{0}</eqn><span>({1})</span></section>',
208209
"tag": "\\[",
209210
},
210211
{
211212
"name": "math_block",
212-
"rex": re.compile(r"^\\\[([\s\S]+?)\\\]", re.M),
213+
"rex": re.compile(r"^\\\[([\s\S]+?)\\\]", re.MULTILINE),
213214
"tmpl": "<section>\n<eqn>{0}</eqn>\n</section>\n",
214215
"tag": "\\[",
215216
},
@@ -228,14 +229,14 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
228229
{
229230
"name": "math_block_eqno",
230231
"rex": re.compile(
231-
r"^`{3}math\s+?([^`]+?)\s+?`{3}\s*?\(([^)$\r\n]+?)\)", re.M
232+
r"^`{3}math\s+?([^`]+?)\s+?`{3}\s*?\(([^)$\r\n]+?)\)", re.MULTILINE
232233
),
233234
"tmpl": '<section class="eqno">\n<eqn>{0}</eqn><span>({1})</span>\n</section>\n',
234235
"tag": "```math",
235236
},
236237
{
237238
"name": "math_block",
238-
"rex": re.compile(r"^`{3}math\s+?([^`]+?)\s+?`{3}", re.M),
239+
"rex": re.compile(r"^`{3}math\s+?([^`]+?)\s+?`{3}", re.MULTILINE),
239240
"tmpl": "<section>\n<eqn>{0}</eqn>\n</section>\n",
240241
"tag": "```math",
241242
},
@@ -270,14 +271,14 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
270271
{
271272
"name": "math_block_eqno",
272273
"rex": re.compile(
273-
r"^`{3}math\s+?([^`]+?)\s+?`{3}\s*?\(([^)$\r\n]+?)\)", re.M
274+
r"^`{3}math\s+?([^`]+?)\s+?`{3}\s*?\(([^)$\r\n]+?)\)", re.MULTILINE
274275
),
275276
"tmpl": '<section class="eqno"><eqn>{0}</eqn><span>({1})</span></section>',
276277
"tag": "```math",
277278
},
278279
{
279280
"name": "math_block",
280-
"rex": re.compile(r"^`{3}math\s+?([^`]+?)\s+?`{3}", re.M),
281+
"rex": re.compile(r"^`{3}math\s+?([^`]+?)\s+?`{3}", re.MULTILINE),
281282
"tmpl": "<section><eqn>{0}</eqn></section>",
282283
"tag": "```math",
283284
},
@@ -295,13 +296,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
295296
"block": [
296297
{
297298
"name": "math_block_eqno",
298-
"rex": re.compile(r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)", re.M),
299+
"rex": re.compile(
300+
r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)", re.MULTILINE
301+
),
299302
"tmpl": '<section class="eqno"><eqn>{0}</eqn><span>({1})</span></section>',
300303
"tag": "$$",
301304
},
302305
{
303306
"name": "math_block",
304-
"rex": re.compile(r"^\${2}([^$]*?)\${2}", re.M),
307+
"rex": re.compile(r"^\${2}([^$]*?)\${2}", re.MULTILINE),
305308
"tmpl": "<section><eqn>{0}</eqn></section>",
306309
"tag": "$$",
307310
},
@@ -329,13 +332,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
329332
"block": [
330333
{
331334
"name": "math_block_eqno",
332-
"rex": re.compile(r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)", re.M),
335+
"rex": re.compile(
336+
r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)", re.MULTILINE
337+
),
333338
"tmpl": '<section class="eqno">\n<eqn>{0}</eqn><span>({1})</span>\n</section>\n',
334339
"tag": "$$",
335340
},
336341
{
337342
"name": "math_block",
338-
"rex": re.compile(r"^\${2}([^$]*?)\${2}", re.M),
343+
"rex": re.compile(r"^\${2}([^$]*?)\${2}", re.MULTILINE),
339344
"tmpl": "<section>\n<eqn>{0}</eqn>\n</section>\n",
340345
"tag": "$$",
341346
},

0 commit comments

Comments
 (0)