fix(docs/manualtools.py): use removeprefix instead of lstrip for frontmatter parsing

Replace .lstrip('\n') with .removeprefix("\n") to preserve body text that
legitimately starts with blank lines. The serialize() function inserts exactly
one separator newline; removing only that one newline (via removeprefix) rather
than all leading newlines (via lstrip) maintains parse/serialize roundtrip
losslessness.

Adds regression test to verify bodies with leading blank lines roundtrip
correctly.
This commit is contained in:
2026-07-25 21:11:40 -04:00
parent efa86e8eda
commit 3ccc5d2210
2 changed files with 13 additions and 1 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ def parse(path: Path) -> tuple[dict, str]:
if end == -1:
return {}, text.rstrip()
fm = yaml.safe_load(text[4:end]) or {}
return fm, text[end + 5 :].lstrip('\n').rstrip()
return fm, text[end + 5 :].removeprefix("\n").rstrip()
def serialize(fm: dict, body: str) -> str: