-
-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Summary
Add support for multi-line table cells using trailing backslash (\) continuation syntax. This would allow cell content to span multiple source lines for improved readability.
Proposed Syntax
Row-Level Continuation (Preferred)
Trailing \ at row end continues the entire row on the next line:
| Name | Description | \
| | This is additional content for column 2. |
Rationale for preference:
- Cleaner visual alignment in source
- Each line is still a complete row structure
- Easier to parse (row-level state, not cell-level)
- Works naturally with colspan (content goes to same logical cell)
Alternative: Cell-Level Continuation
Trailing \ before closing | continues only that cell:
| Name | A very long description that needs to \ |
| | continue on the next line. |
This is more granular but requires tracking per-cell continuation state.
Content Merging
When lines are merged:
- Strip trailing
\and surrounding whitespace - Join with a single space (like soft breaks in paragraphs)
- Result:
"content \n more"→"content more"
Interaction with Related Features
PR #8: Creole-Style Tables
Multi-line cells should work with:
- Colspan (
||): Continuation applies to the logical merged cell - Rowspan (
|^): Continuation lines can include rowspan markers - Header cells (
|=): Headers can span multiple lines
|= Feature |= Long Description Header || \
| | that spans two columns and two lines ||
Issue #18: Table Attributes
Row-level continuation should preserve attributes:
| Cell A | Cell B |{.highlight} \
| | more B |
The {.highlight} applies to the merged row.
Cell attributes on continuation lines could either:
- Merge with previous attributes
- Override previous attributes
- Be an error (simpler)
Recommendation: Only allow attributes on the first line of a continued row.
Alignment
Continuation lines inherit alignment from the separator row:
| Left | Center | Right |
|:-------|:----------:|----------|
| Short | A longer \ | Right |
| | centered | |
| | paragraph | |
Edge Cases
- Empty continuation cells:
| \ |on continuation = skip column (use previous content only) - Code spans across lines: Not supported (code spans must be single-line)
- Escaped backslash:
\\|at line end = literal\, no continuation - Trailing whitespace:
| content \ |(spaces after\) = continuation - Last row + caption:
\does not affect^caption parsing
Implementation Approach
- Feature flag:
TableExtensions::MULTILINE_CELLS(opt-in, non-standard) - Parser changes in
BlockParser::tryParseTable():- Detect trailing
\before final| - Collect subsequent lines until non-continuation row
- Merge cell contents before creating TableCell nodes
- Detect trailing
- Minimal renderer changes: None needed (cells receive merged content)
Why Row-Level is Preferred
| Aspect | Row-Level \ |
Cell-Level \ |
|---|---|---|
| Parsing complexity | Lower | Higher |
| Visual alignment | Better | Harder to maintain |
| Colspan interaction | Natural | Ambiguous |
| State tracking | Row-level only | Per-cell state needed |
| Error recovery | Simpler | Complex |
Standard Djot Spec
Per the djot specification:
"Contents of table cells are parsed as inlines."
This means:
- Inline formatting (emphasis, links, code) works
- Block-level content (paragraphs, lists) is NOT supported
- Each cell is inherently single-line
So we dont change the specs, we extend it here.
For cases, where the line length would be too exceeded and such a multiline display would help the formatting/readability.
Related
- PR Add Creole-style |= table header syntax #8: Creole-style table extensions (header cells, colspan, rowspan)
- Issue Add attribute support for table rows and cells #18: Table row/cell attributes
- Issue Djot-Extra: Optional Syntax Extension: Definition-Style Metadata #12: Djot-Extra optional syntax extensions
Open Questions
- Should continuation lines require the same column count?
- How to handle mixed continuation + non-continuation rows?
- Should we support
\in caption lines?