Commit graph

1 commit

Author SHA1 Message Date
Ash Gupta
e9349ce66a
fix(markdown): handle CRLF line endings in section heading parser (#1469)
* fix(markdown): handle CRLF line endings in section heading parser

split('\n') on CRLF content leaves a trailing \r on each line, and the
heading regex /^(#{1,6})\s+(.+)$/ (anchored with $) fails to match
'## Heading\r' because $ matches before end-of-string, not before \r.
Result: Windows-authored markdown silently produces zero Section nodes.

Use split(/\r\n|\r|\n/) to normalize all line-ending conventions.

Pure additive — LF-only files produce identical output. CR-only (Mac OS
Classic) becomes tolerated as a side benefit at zero risk.

Adds integration test markdown-processor-crlf.test.ts covering LF
baseline, CRLF (the regression), CR-only, mixed, and startLine/endLine
correctness.

* test(markdown): strengthen CRLF integration tests + clarify split comment

- Assert section names, levels, line spans, and CONTAINS hierarchy (not only counts)
- Document trailing-newline effect on endLine via exact toEqual expectations
- Reword markdown-processor comment: \$ only at end-of-string vs .+ before \\r

Co-authored-by: Cursor <cursoragent@cursor.com>

* chore: empty commit

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-14 08:58:58 +01:00