Skip to content

Commit c4ea732

Browse files
committed
Reuse _get_indent in _process_start_markers
1 parent 926d7c7 commit c4ea732

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

markdown_code_runner.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -265,23 +265,21 @@ def _process_start_markers(
265265
verbose: bool = False, # noqa: FBT001, FBT002, ARG002
266266
) -> str | None:
267267
for marker_name in MARKERS:
268-
if marker_name.endswith(":start"):
269-
match = is_marker(line, marker_name)
270-
if match:
271-
# reset output in case previous output wasn't displayed
272-
self.output = None
273-
self.backtick_options = _extract_backtick_options(line)
274-
self.section, _ = marker_name.rsplit(":", 1) # type: ignore[assignment]
275-
self.indent = match.group("spaces")
276-
277-
# Standardize backticks if needed
278-
if (
279-
marker_name == "code:backticks:start"
280-
and self.backtick_standardize
281-
and "markdown-code-runner" in line
282-
):
283-
return re.sub(r"\smarkdown-code-runner.*", "", line)
284-
return line
268+
if marker_name.endswith(":start") and is_marker(line, marker_name):
269+
# reset output in case previous output wasn't displayed
270+
self.output = None
271+
self.backtick_options = _extract_backtick_options(line)
272+
self.section, _ = marker_name.rsplit(":", 1) # type: ignore[assignment]
273+
self.indent = self._get_indent(line)
274+
275+
# Standardize backticks if needed
276+
if (
277+
marker_name == "code:backticks:start"
278+
and self.backtick_standardize
279+
and "markdown-code-runner" in line
280+
):
281+
return re.sub(r"\smarkdown-code-runner.*", "", line)
282+
return line
285283
return None
286284

287285
@staticmethod

0 commit comments

Comments
 (0)