Skip to content

Fix wrapped {table} captions becoming body paragraphs - #1195

Open
BetterAndBetterII wants to merge 2 commits into
executablebooks:masterfrom
BetterAndBetterII:fix/table-wrapped-caption
Open

Fix wrapped {table} captions becoming body paragraphs#1195
BetterAndBetterII wants to merge 2 commits into
executablebooks:masterfrom
BetterAndBetterII:fix/table-wrapped-caption

Conversation

@BetterAndBetterII

Copy link
Copy Markdown

Summary

MyST takes directive arguments from the opening fence line only. A hard-wrapped {table} caption (common at ~70 columns) therefore becomes a leading paragraph in the body, and RSTTable fails with "exactly one table expected" even though the Markdown is otherwise valid.

Fold leading non-table body lines into the table caption argument when a Markdown/rST table follows. Single-line captions and unrelated invalid body content are unchanged.

Test plan

  • Unit tests for wrapped and single-line captions (tests/test_renderers/test_parse_directives.py)
  • Sphinx fixture case in sphinx_directives.md
  • pytest tests/test_renderers/test_parse_directives.py tests/test_renderers/test_fixtures_sphinx.py

Fixes #1104

MyST only takes the directive argument from the opening fence line, so a
hard-wrapped table caption leaked into the body and RSTTable failed with
"exactly one table expected". Fold leading non-table body lines into the
caption when a table follows.

Fixes executablebooks#1104
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.

Long captions break table directive (in HTML output by Sphinx)

1 participant