Fold the blank-text and length guards of code_span into one padding rule, which the hand mutants of its lines all fail

This commit is contained in:
2026-11-17 04:23:01 +01:00
parent 2e44ec95ca
commit a87b9a4d16
+3 -6
View File
@@ -81,12 +81,9 @@ def code_span(line: str, at: int) -> tuple[str, int] | None:
if opened is None or closed is None:
return None
text = line[opened.end():opened.end() + closed.start()]
if len(run) > 1:
if not text.strip():
return None
# A space at both ends is padding, which keeps a backtick at either end of the text apart from the run. Without one at both ends, the span is its text.
if len(text) >= 3 and text.startswith(" ") and text.endswith(" "):
text = text[1:-1]
# In a longer run, a space at both ends is padding, which keeps a backtick at either end of the text apart from the run. Without one at both ends, the span is its text.
if len(run) > 1 and text.startswith(" ") and text.endswith(" "):
text = text[1:-1]
return (text, opened.end() + closed.end()) if text else None