Skip to content

Conversation

@dereuromark
Copy link
Contributor

@dereuromark dereuromark commented Nov 30, 2025

Summary

This PR adds extended table features to djot-php, providing more flexible table authoring options while maintaining full backward compatibility with standard djot syntax.

Features

1. Creole-style Header Cells (|=)

Mark individual cells as headers using the |= prefix (must be directly attached to pipe):

|= Name |= Age |
| Alice | 28   |
| Bob   | 34   |

Renders as:

<table>
<tr><th>Name</th><th>Age</th></tr>
<tr><td>Alice</td><td>28</td></tr>
<tr><td>Bob</td><td>34</td></tr>
</table>

2. Cell Alignment Markers

Alignment markers must be directly attached to |= (no space):

Syntax Alignment
|=< text Left
|=> text Right
|=~ text Center

Example:

|=< Left |=~ Center |=> Right |
| A      | B        | C       |

3. Colspan Support

Empty cells merge with the previous cell:

|= Name       ||= Details |
| First | Last | Age      |

The Name header spans 2 columns.

4. Rowspan Support

Use |^ (directly attached) to continue from the cell above:

|= Category |= Item  |
| Fruit     | Apple  |
|^          | Banana |
|^          | Orange |

The Fruit cell spans 3 rows.

5. Header Rowspan

Combine header and rowspan with |=^:

|= Group |= A |= B |
|=^      | 1  | 2  |
|=^      | 3  | 4  |

Compatibility Notes

Important: All special markers must be directly attached to the pipe character:

Input Interpretation
|= text Header cell with content "text"
| = text Regular cell with content "= text"
|^ Rowspan marker
| ^ Regular cell with content "^"
|=< Left-aligned header
|= < Header with content "< ..."

This prevents false positives when users want literal =, ^, <, >, or ~ characters in their cells.

Additional compatibility:

  • Traditional separator row syntax (|---|) continues to work as expected
  • Mixed usage is supported: separator rows and |= syntax can coexist

Test Coverage

  • All new features have comprehensive test coverage
  • Tests verify marker attachment requirement (spaces prevent special interpretation)
  • Backward compatibility verified with existing table tests

RFC Status

This extends beyond the standard djot specification. The syntax choices prioritize:

  • Familiarity (Creole/MediaWiki-style |= for headers)
  • Simplicity (single-character markers)
  • Safety (markers must be attached to avoid false positives with literal content)

Future Considerations

Per-cell alignment for data cells (e.g., |< left | or |> right |) is not included in this PR. This would require a different syntax to avoid conflicts with literal < and > characters which are common in table data (comparisons like < 5, > 10, math expressions, etc.). This could be revisited in a future PR if there's demand, e.g.

|:< to left side |:> to right side |:~ centered |

Both mixed

If both are defined, the header would only align itself, and the meta row would define for the cells below:

|= Name  |=< Age |
|:------|----:|
| Alice | 28  |

Related

TBD

  • Include row/col spans using | and ^ ?
  • Multi-line Cells using \ ?

This is also a more intensive change of the specs, while still being fully compliant, this does make documents that use this not working with other parsers.
So we would need a clear sign-off from the spec author(s) IMO before we go down this road - or it must be a clear feature flag.

@codecov
Copy link

codecov bot commented Nov 30, 2025

Codecov Report

❌ Patch coverage is 97.80220% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.36%. Comparing base (5bb7d67) to head (56cc772).
⚠️ Report is 27 commits behind head on master.

Files with missing lines Patch % Lines
src/Node/Block/TableCell.php 75.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master       #8      +/-   ##
============================================
+ Coverage     93.28%   93.36%   +0.08%     
- Complexity     1672     1695      +23     
============================================
  Files            59       59              
  Lines          4347     4434      +87     
============================================
+ Hits           4055     4140      +85     
- Misses          292      294       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Adds support for marking header cells with |= prefix instead of requiring
a separator row. This is simpler and more intuitive, especially for users
coming from wiki markup.

Features:
- |= Cell marks a header cell
- |=< Left-aligned header
- |=> Right-aligned header
- |=~ Center-aligned header

The traditional separator row syntax continues to work unchanged.

See: jgm/djot#354
@dereuromark dereuromark force-pushed the feature/table-header-equals-syntax branch from ad3e8ae to 09c86ed Compare November 30, 2025 04:22
@dereuromark dereuromark added extra beyond standard/specs RFC labels Dec 1, 2025
dereuromark and others added 2 commits December 1, 2025 21:56
When using |=< |=> |=~ alignment markers on header cells, the alignment
now applies to the entire column (subsequent data rows), not just the
header cell itself.

Separator row alignment still takes precedence if present.
dereuromark added a commit that referenced this pull request Dec 5, 2025
Addresses TBD items from PR #8:
- Row/column spans using || (colspan) and |^ (rowspan)
- Multi-line cells using trailing \ continuation
- Interaction between |= headers and spanning syntax

All features are strictly opt-in and compatible with original djot specs.
@dereuromark dereuromark force-pushed the feature/table-header-equals-syntax branch from 7080f78 to ea5d384 Compare December 5, 2025 22:14
dereuromark and others added 5 commits December 5, 2025 23:33
Implements cell spanning syntax for tables:
- Colspan: || (empty cells) after content spans multiple columns
- Rowspan: |^| continues a cell from the row above
- Header rowspan: |=^ for header cells that span rows

Features:
- TableCell node now has colspan and rowspan properties
- HtmlRenderer outputs colspan/rowspan attributes
- Compatible with |= header syntax from PR #8
- Standard djot tables work unchanged (opt-in extension)

Syntax examples:
- |= Header || (colspan=2)
- |^ | (rowspan continuation)
- |=^ | (header rowspan)
Fixes false positives where spaces before markers would trigger
special behavior:
- | = text | now renders as literal "= text", not a header
- | ^ | now renders as literal "^", not a rowspan marker
- |= < text | now renders header with "< text", not left-aligned

Markers must be directly attached: |=, |^, |=<, |=>, |=~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extra beyond standard/specs RFC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants