Skip to content

Preserve frontmatter format after leading whitespace - #145

Open
himanshu748 wants to merge 1 commit into
eyeseast:mainfrom
himanshu748:fix/leading-whitespace-handler
Open

himanshu748 wants to merge 1 commit into
eyeseast:mainfrom
himanshu748:fix/leading-whitespace-handler

Conversation

@himanshu748

Copy link
Copy Markdown

Leading whitespace is already stripped by parse(), so JSON and TOML metadata load successfully. However, loads() detects the handler before that normalization and stores None on the post. Dumping the post then silently converts its frontmatter to YAML.

Normalize the input before format detection in loads() so the retained handler agrees with the parser. Regression coverage checks YAML, JSON and TOML with leading blank lines or mixed whitespace through both loads() and text-stream load(), and verifies identical serialization to the unprefixed input.

Validation: the regression failed in all 12 subcases before the fix. Afterward, pytest . --doctest-modules --doctest-glob README.md passes all 68 tests and mypy . passes.

This is separate from #139 (binary stream decoding) and #140 (nested JSON boundaries); neither path is changed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant