Skip to content

Trim blank lines after the header in CR-only documents - #194

Merged
matt-edmondson merged 2 commits into
mainfrom
fix/184-cr-only-body-trim
Oct 7, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
fix/184-cr-only-body-trim

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #184

Before: with CR-only line endings, ExtractBody("---\rtitle: x\r---\r\r\rBody\r") returned "\r\rBody", and RemoveFrontmatter / ReplaceFrontmatter kept the same blank lines. LF and CRLF documents give "Body".

After: all three line endings give the same body.

How: TrimBody advanced past leading blank lines only on '\n'. It now treats '\r' as a line end too. For CRLF it still lands after the '\n'.

Tests: LineEndingTests gains CR/LF/CRLF cases for ExtractBody, RemoveFrontmatter and ReplaceFrontmatter on a document with blank lines after the header. The three CR cases fail without the change and pass with it. Full suite: 273 passed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ho7QngpAmRRAxjmT2qp1sn


Generated by Claude Code

claude added 2 commits October 7, 2026 02:24
TrimBody only treated '\n' as a line end, so a CR-only document kept its
blank lines after the header: ExtractBody returned "\r\rBody" where LF and
CRLF give "Body", and RemoveFrontmatter and ReplaceFrontmatter carried the
same stray lines into their output. Treat '\r' as a line end as well; CRLF
still lands after its '\n'.

Fixes #184

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ho7QngpAmRRAxjmT2qp1sn
The build's ktsu.Sdk sync rewrote it, and it was committed by mistake.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ho7QngpAmRRAxjmT2qp1sn
@sonarqubecloud

sonarqubecloud Bot commented Oct 7, 2026

Copy link
Copy Markdown

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.

With CR-only line endings, ExtractBody/RemoveFrontmatter/ReplaceFrontmatter keep the blank lines after the header ("\r\rBody" instead of "Body")

2 participants