-
Notifications
You must be signed in to change notification settings - Fork 44
Improve CRLF handling in the decoder #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Hi @smortezah, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances cross-platform compatibility by normalizing different line ending formats (CRLF, CR, LF) to a consistent LF format before parsing, preventing issues with files created on different operating systems.
Key Changes:
- Added line ending normalization logic in the scanner to handle Windows (CRLF) and old Mac (CR) formats
- Implemented comprehensive test coverage for CRLF/CR handling in both scanner and decoder
- Ensured escaped sequences in quoted strings are preserved during normalization
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/toon_format/_scanner.py | Added line ending normalization logic to convert CRLF and CR to LF |
| tests/test_scanner.py | Added TestCRLFHandling class with tests for various line ending scenarios |
| tests/test_decoder.py | Added TestCRLFDecoding class to verify decoder handles different line endings correctly |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bpradana
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved despite CI failed on lint
🚀🚀🚀
Updating comments for specificity of replacing characters Co-authored-by: Copilot <[email protected]>
This pull request improves cross-platform compatibility in the
toon_formatscanner and decoder by normalizing different line endings (Windows CRLF and old Mac CR) to LF, ensuring consistent parsing behavior regardless of the source file's origin. It also adds comprehensive tests to verify correct handling of various line ending scenarios.Line ending normalization:
src/toon_format/_scanner.pyto normalize Windows CRLF (\r\n) and old Mac CR (\r) line endings to LF (\n) before parsing, preventing stray carriage return characters from appearing in parsed content.Test coverage improvements:
TestCRLFDecodingintests/test_decoder.pyto verify that the decoder correctly handles CRLF, CR, mixed line endings, and quoted strings containing escaped\rand\nsequences, including strict mode decoding.TestCRLFHandlingintests/test_scanner.pyto ensure the scanner normalizes all types of line endings, preserves indentation, and works correctly in strict mode.