Skip to content

Fix math block rendering broken by CRLF line endings - #52

Merged
patakuti merged 1 commit into
mainfrom
fix/crlf-math-block
May 18, 2026
Merged

Fix math block rendering broken by CRLF line endings#52
patakuti merged 1 commit into
mainfrom
fix/crlf-math-block

Conversation

@patakuti

Copy link
Copy Markdown
Owner

Closes #51

Summary

  • Normalize CRLF (\r\n) to LF (\n) at the start of Convert so PreprocessMathBlocks and goldmark receive consistent line endings
  • Add regression test TestConvert_CRLFMathBlock in convert_test.go

Root cause

PreprocessMathBlocks splits on \n, leaving a trailing \r on each line with CRLF input.
bytes.TrimRight(body, " \t") does not strip \r, so the closing $$\r line was misdetected as having content $ before the delimiter, corrupting the math block structure.

Test plan

  • go test ./internal/markdown/... -run TestConvert_CRLFMathBlock passes
  • All existing tests pass (go test ./...)
  • make build succeeds

🤖 Generated with Claude Code

Normalize CRLF to LF at the start of Convert so PreprocessMathBlocks
and goldmark receive consistent line endings. Without this, the trailing
\r left on each line caused the closing $$ detector to misidentify
content, breaking display math rendering for Windows-style files.

Add regression test in convert_test.go.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@patakuti
patakuti merged commit ecbc68a into main May 18, 2026
1 check passed
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.

Math block not rendered when file uses CRLF line endings

1 participant