Skip to content

Commit 741e29d

Browse files
committed
The code has been refactored.
1 parent f03ff8e commit 741e29d

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,7 @@ _archive/
133133

134134
.vscode/
135135
.DS_Store
136+
.idea/
137+
136138

137139
docs/apidocs

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ repos:
2121
- id: trailing-whitespace
2222

2323
- repo: https://github.com/astral-sh/ruff-pre-commit
24-
rev: v0.8.4
24+
rev: v0.9.3
2525
hooks:
2626
- id: ruff
2727
args: [--fix]
2828
- id: ruff-format
2929

3030
- repo: https://github.com/pre-commit/mirrors-mypy
31-
rev: v1.14.0
31+
rev: v1.14.1
3232
hooks:
3333
- id: mypy
3434
args: [--config-file=pyproject.toml]

myst_parser/config/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def __repr__(self) -> str:
312312
metadata={
313313
"validator": check_heading_slug_func,
314314
"help": (
315-
"Return a case- and whitespace-normalized name."
315+
"Function for normalizing text to valid html id value"
316316
"or a python import path e.g. `my_package.my_module.my_function`"
317317
"It can be used to transliterate any language to valid stable html identifiers"
318318
),
@@ -536,8 +536,7 @@ def merge_file_level(
536536
if "html_meta" in topmatter:
537537
warning(
538538
MystWarnings.MD_TOPMATTER,
539-
"top-level 'html_meta' key is deprecated, "
540-
"place under 'myst' key instead",
539+
"top-level 'html_meta' key is deprecated, place under 'myst' key instead",
541540
)
542541
updates["html_meta"] = topmatter["html_meta"]
543542
if "substitutions" in topmatter:

myst_parser/parsers/docutils_.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ def _attr_to_optparse_option(at: Field, default: Any) -> tuple[dict[str, Any], s
139139
"metavar": "<boolean>",
140140
"validator": frontend.validate_boolean,
141141
}, str(default)
142-
if at.type is str or at.name in ("heading_slug_func", "fully_normalize_name_slug_func"):
142+
if at.type is str or at.name in (
143+
"heading_slug_func",
144+
"fully_normalize_name_slug_func",
145+
):
143146
return {
144147
"metavar": "<str>",
145148
}, f"(default: '{default}')"
@@ -278,7 +281,7 @@ def parse(self, inputstring: str, document: nodes.document) -> None:
278281
for i, line in enumerate(inputstring.split("\n")):
279282
if len(line) > document.settings.line_length_limit:
280283
error = document.reporter.error(
281-
f"Line {i+1} exceeds the line-length-limit:"
284+
f"Line {i + 1} exceeds the line-length-limit:"
282285
f" {document.settings.line_length_limit}."
283286
)
284287
document.append(error)
@@ -479,7 +482,7 @@ def visit_rubric_html(self, node):
479482
So here we override the visit/depart methods to output the correct <h> element
480483
"""
481484
if "level" in node:
482-
self.body.append(self.starttag(node, f'h{node["level"]}', "", CLASS="rubric"))
485+
self.body.append(self.starttag(node, f"h{node['level']}", "", CLASS="rubric"))
483486
else:
484487
self.body.append(self.starttag(node, "p", "", CLASS="rubric"))
485488

@@ -490,7 +493,7 @@ def depart_rubric_html(self, node):
490493
See explanation in `visit_rubric_html`
491494
"""
492495
if "level" in node:
493-
self.body.append(f'</h{node["level"]}>\n')
496+
self.body.append(f"</h{node['level']}>\n")
494497
else:
495498
self.body.append("</p>\n")
496499

0 commit comments

Comments
 (0)