Skip to content

Preserve nested table content when padding tables - #461

Open
civilwarinfrance wants to merge 3 commits into
Alir3z4:masterfrom
civilwarinfrance:fix/nested-table-padding
Open

civilwarinfrance wants to merge 3 commits into
Alir3z4:masterfrom
civilwarinfrance:fix/nested-table-padding

Conversation

@civilwarinfrance

Copy link
Copy Markdown

Fixes #370.

With pad_tables enabled, nested table markers are treated as alternating start/end markers. A minimal nested table crashes with IndexError; when a marker shares a line with text, that text can also disappear.

Track marker nesting depth and finish padding only when the outer table ends. Nested tables fall back to their unpadded output, retaining text on marker lines and the surrounding quote prefix. Flat tables before and after the nested block keep normal padding.

Validation:

  • All 13 new regression cases fail on the original implementation; all 209 tests pass after the change (Python 3.14.6).
  • The CLI reproducer succeeds with --pad-tables.
  • 200 generated quoted/unquoted documents, including sibling tables and depths up to five, preserve the unpadded converter's text-token order at body widths 0 and 78.
  • Full flake8, isort, and strict mypy (8 source files) pass; Black passes for both changed Python files.

Updated the changelog and contributor list as requested by the contribution guide.

AI assistance: This patch, tests and description were prepared with Codex (GPT-6).

This branch has not been deployed

No deployments
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.

IndexError when padding nested tables

1 participant