fix: honor table headerRows: 0 in Markdown serialization#2887
Merged
Conversation
🦋 Changeset detectedLatest commit: eedc411 The changes in this PR will be included in the next version bump. This PR includes changesets to release 15 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📦 Bundle Stats —
|
| Metric | Value | vs main (0b82b78) |
|---|---|---|
| Internal (raw) | 792.8 KB | - |
| Internal (gzip) | 151.5 KB | - |
| Bundled (raw) | 1.40 MB | +544 B, +0.0% |
| Bundled (gzip) | 315.7 KB | +151 B, +0.0% |
| Import time | 97ms | -2ms, -2.3% |
@portabletext/editor/behaviors
| Metric | Value | vs main (0b82b78) |
|---|---|---|
| Internal (raw) | 467 B | - |
| Internal (gzip) | 207 B | - |
| Bundled (raw) | 424 B | - |
| Bundled (gzip) | 171 B | - |
| Import time | 2ms | -0ms, -2.6% |
@portabletext/editor/plugins
| Metric | Value | vs main (0b82b78) |
|---|---|---|
| Internal (raw) | 2.7 KB | - |
| Internal (gzip) | 894 B | - |
| Bundled (raw) | 2.5 KB | - |
| Bundled (gzip) | 827 B | - |
| Import time | 7ms | -0ms, -2.2% |
@portabletext/editor/selectors
| Metric | Value | vs main (0b82b78) |
|---|---|---|
| Internal (raw) | 79.7 KB | - |
| Internal (gzip) | 14.6 KB | - |
| Bundled (raw) | 75.2 KB | - |
| Bundled (gzip) | 13.5 KB | - |
| Import time | 8ms | -0ms, -1.9% |
@portabletext/editor/traversal
| Metric | Value | vs main (0b82b78) |
|---|---|---|
| Internal (raw) | 26.2 KB | - |
| Internal (gzip) | 5.2 KB | - |
| Bundled (raw) | 26.1 KB | - |
| Bundled (gzip) | 5.1 KB | - |
| Import time | 6ms | -0ms, -1.8% |
@portabletext/editor/utils
| Metric | Value | vs main (0b82b78) |
|---|---|---|
| Internal (raw) | 29.7 KB | - |
| Internal (gzip) | 6.2 KB | - |
| Bundled (raw) | 27.3 KB | - |
| Bundled (gzip) | 5.8 KB | - |
| Import time | 6ms | -0ms, -2.2% |
🗺️ . · ./behaviors · ./plugins · ./selectors · ./traversal · ./utils · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📦 Bundle Stats — @portabletext/markdown
Compared against main (0b82b78e)
| Metric | Value | vs main (0b82b78) |
|---|---|---|
| Internal (raw) | 53.8 KB | +762 B, +1.4% |
| Internal (gzip) | 9.8 KB | +198 B, +2.0% |
| Bundled (raw) | 348.9 KB | +767 B, +0.2% |
| Bundled (gzip) | 96.3 KB | +195 B, +0.2% |
| Import time | 40ms | -1ms, -3.0% |
🗺️ View treemap · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
`portableTextToMarkdown` ignored a table's `headerRows` and always promoted `rows[0]` to the GFM header, so a headerless table (`headerRows: 0`) lost that fact on export: `rows[0]` was reinterpreted as a header and the round-trip back through `markdownToPortableText` returned `headerRows: 1`. pt->md (`DefaultTableRenderer`): `headerRows === 0` now emits an empty header row (padded to the column count) plus the delimiter, with every row in the body. Any other value (`undefined` or `>= 1`) still promotes `rows[0]`; GFM's single header row means header rows beyond the first flatten into the body (lossy, preserved on the PT side). md->pt: an all-empty header row is dropped and recorded as `headerRows: 0` (an explicit 0, distinct from the no-table-header `undefined` fallback); a non-empty header stays `headerRows: 1`. Markdown only ever emits 0 or 1, so a headerless table round-trips cleanly and no phantom empty header row is introduced. `headerRows` stays `number`, so this is a serialization-behavior change, not an API break: the existing "`headerRows: 0` promotes the first row" test flips, and a `markdownToPortableText` test pins the empty-header read-back.
df333f1 to
eedc411
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
portableTextToMarkdownignored a table'sheaderRowsfield and always promotedrows[0]to the GFM header. A headerless table (headerRows: 0) lost that fact on export,rows[0]was reinterpreted as the header, and the round-trip back throughmarkdownToPortableTextreturnedheaderRows: 1.pt→md (
DefaultTableRenderer):headerRows === 0now emits an empty header row (padded to the column count) plus the delimiter, with every row in the body. Any other value (undefinedor>= 1) still promotesrows[0]. GFM allows a single header row, so header rows beyond the first flatten into the body (lossy, and the extra rows stay on the Portable Text side).md→pt: an all-empty header row is dropped and recorded as an explicit
headerRows: 0(distinct from the pre-existing no-headerundefinedfallback); a non-empty header staysheaderRows: 1. Markdown only ever emits 0 or 1, so a headerless table round-trips cleanly with no phantom empty header row.Round-trips:
0 → empty-header md → 0;1 → header md → 1;>= 2 → single-header md → 1(lossy on export,> 1preserved in the PT source, documented).headerRowsstaysnumber, so this is a serialization-behavior change, not an API break. The existingportable-text-to-markdown"headerRows: 0promotes the first row" test flips (now asserts the empty header + full body), and a newmarkdown-to-portable-texttest pins the empty-header read-back toheaderRows: 0with only the body rows (full-literaltoEqual, deterministic keys). All 292 markdown-package tests pass; types/lint/build/knip/format green.Out of scope (follow-up): the ticket notes
@portabletext/plugin-table's header feature should adopt the sameheaderRows: number. Happy to file that separately.