feat(table): visible markers for leading/trailing whitespace in string cells#9256
feat(table): visible markers for leading/trailing whitespace in string cells#9256kirangadhave merged 5 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Pull request overview
Adds UI support in the data table to make leading/trailing whitespace in string cells visually distinguishable, while keeping inner whitespace rendering unchanged; also updates smoke-test coverage and adds unit tests.
Changes:
- Add a
splitLeadingTrailingWhitespace()utility and use it in table cell rendering to show edge-only whitespace markers. - Introduce
WhitespaceMarkersrendering for edge whitespace and enhance whitespace sentinel rendering for uncommon whitespace via\\uXXXXescapes. - Update the whitespace/sentinel smoke-test notebook and add frontend unit tests for the new behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| marimo/_smoke_tests/tables/whitespace_sentinel_rendering.py | Expands the smoke-test notebook with an edge-whitespace section and updated expected-rendering notes |
| frontend/src/components/data-table/utils.ts | Adds splitLeadingTrailingWhitespace() and keeps whitespace-only sentinel detection |
| frontend/src/components/data-table/sentinel-cell.tsx | Enhances whitespace marker rendering and exports WhitespaceMarkers for non-sentinel strings |
| frontend/src/components/data-table/columns.tsx | Integrates edge-whitespace splitting/markers into string cell rendering and URL detection parsing |
| frontend/src/components/data-table/tests/utils.test.ts | Adds unit tests for splitLeadingTrailingWhitespace() |
| frontend/src/components/data-table/tests/sentinel-cell.test.tsx | Adds unit tests for WhitespaceMarkers rendering and descriptions |
Comments suppressed due to low confidence (2)
marimo/_smoke_tests/tables/whitespace_sentinel_rendering.py:390
- This markdown says Unicode whitespace “render[s] as the raw char since
WHITESPACE_CHARShas no mapping”, butrenderWhitespaceMarkersnow renders unknown whitespace as\\uXXXXescapes. Update the notebook text to match the current frontend behavior.
marimo/_smoke_tests/tables/whitespace_sentinel_rendering.py:33 - The “Expected rendering” markdown has two issues: (1)
Empty string "\"does not represent an empty string—this should be shown as""; and (2) the whitespace-only examples include a literal tab/newline, which splits the list item across lines and can render incorrectly. Prefer escaped examples like\tand\ninside the inline code.
| " ": { marker: "\u2423", name: "space" }, | ||
| "\t": { marker: "\\t", name: "tab" }, | ||
| "\n": { marker: "\\n", name: "newline" }, | ||
| "\r": { marker: "\\r", name: "newline" }, |
Bundle ReportChanges will increase total bundle size by 226.32kB (0.91%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: marimo-esmAssets Changed:
Files in
|
There was a problem hiding this comment.
Pull request overview
Adds visible inline markers for leading/trailing whitespace in string cells in the data table, so values like " abc" and "abc " are distinguishable from "abc" while preserving inner whitespace. This addresses #9244 and extends existing sentinel rendering for whitespace-only strings.
Changes:
- Add a utility to split strings into leading/middle/trailing whitespace segments.
- Render edge whitespace markers in normal and popout (long string) table cells, while keeping URL detection focused on the non-whitespace middle.
- Extend smoke test notebook and add unit tests for the new splitting/marker behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| marimo/_smoke_tests/tables/whitespace_sentinel_rendering.py | Updates smoke-test notebook to cover edge-whitespace markers and additional cases. |
| frontend/src/components/data-table/utils.ts | Adds splitLeadingTrailingWhitespace utility and related regex constants. |
| frontend/src/components/data-table/sentinel-cell.tsx | Adds WhitespaceMarkers component and improves whitespace marker rendering (incl. unicode escapes). |
| frontend/src/components/data-table/columns.tsx | Integrates edge-whitespace markers into cell rendering and popout triggers; adjusts URL parsing to ignore padding whitespace. |
| frontend/src/components/data-table/tests/utils.test.ts | Adds unit tests for splitLeadingTrailingWhitespace. |
| frontend/src/components/data-table/tests/sentinel-cell.test.tsx | Adds unit tests for WhitespaceMarkers rendering and labeling. |
| frontend/src/components/data-table/tests/columns.test.tsx | Adds tests ensuring edge markers render while URL detection still works. |
Comments suppressed due to low confidence (2)
marimo/_smoke_tests/tables/whitespace_sentinel_rendering.py:34
- The markdown for expected rendering has broken/incorrect inline-code examples:
Empty string "\""isn’t a valid representation of an empty string, and the whitespace-only bullet contains a literal tab and a literal newline inside backticks, which will break the markdown formatting. Use explicit escaped sequences (e.g."",\t,\n) so the notebook renders reliably and unambiguously.
marimo/_smoke_tests/tables/whitespace_sentinel_rendering.py:390 - This section claims unicode whitespace "render[s] as the raw char since
WHITESPACE_CHARShas no mapping", but the current frontend implementation renders unknown whitespace as\\uXXXXescapes. Please update this notebook text to match the actual behavior so smoke-test expectations are accurate.
📝 Summary
Closes #9244
Strings like
" abc"or"abc "previously rendered identically to"abc"because HTML collapses runs of whitespace. This PR adds inline markers on the edges so leading/trailing whitespace is visually distinguishable, inner whitespace is unchanged./\s/detects a lot of whitespace characters; we specially render space, tab, newline, and CR. For everything else we render the unicode escape sequences. These cases should be rare, but making them visible let's users handle these.Whitespace only strings are rendered specially using sentinel.
Also rendering other
Updated smoke test notebook:
whitespace_sentinel_rendering.pyAdded tests