fix(parser): do not append a table row when a blank line closed the table - #402
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe fragment parser now avoids adding a table separator when a blank line follows the table header. Tests cover blank-line-terminated tables and open tables. ChangesTable Completion
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change prevents fragment completion from appending a phantom table row after a blank line while retaining completion for open tables. Covered boundary and unchanged behaviors leave no current merge-blocking risk. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The bug
MDEx.FragmentParser.complete/2appended a phantom| - |row to a table that had already been closed by a trailing blank line.maybe_complete_table/2only checked that the trailing whitespace starts with\n. It never looked at the rest, so"...| 1 |\n\n"was treated the same as"...| 1 |\n"— an open table still being streamed.Reproducer on
main:During streaming this meant every table rendered with an extra empty row until the end of input.
The change
maybe_complete_table/2now bails out when the trailing whitespace contains a second newline, i.e. a blank line closed the block.A table whose source ends immediately after a row (no blank line) is still considered open and keeps the existing behaviour of getting a separator/row appended.
Tests
Four regression tests in
test/mdex/fragment_parser_test.exscovering the closed-by-blank-line cases (single column, multi column, after another block) plus an assertion that the still-open case is unchanged. Suite goes from 825 to 829 passing; no existing test asserted the old output.Summary by CodeRabbit
Bug Fixes
Tests