Skip to content

feat(table): visible markers for leading/trailing whitespace in string cells#9256

Merged
kirangadhave merged 5 commits intomainfrom
kg/whitespace-markers
Apr 20, 2026
Merged

feat(table): visible markers for leading/trailing whitespace in string cells#9256
kirangadhave merged 5 commits intomainfrom
kg/whitespace-markers

Conversation

@kirangadhave
Copy link
Copy Markdown
Member

📝 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.py

Added tests

Screenshot 2026-04-17 at 3 29 51 PM Screenshot 2026-04-17 at 3 30 11 PM

@kirangadhave kirangadhave requested a review from Light2Dark April 17, 2026 22:33
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Apr 20, 2026 2:39pm

Request Review

@kirangadhave kirangadhave requested a review from mscolnick April 17, 2026 22:33
@kirangadhave kirangadhave added the bug Something isn't working label Apr 17, 2026
@kirangadhave kirangadhave changed the title Kg/whitespace markers feat(table): visible markers for leading/trailing whitespace in string cells Apr 17, 2026
@kirangadhave kirangadhave added enhancement New feature or request and removed bug Something isn't working labels Apr 17, 2026
mscolnick
mscolnick previously approved these changes Apr 18, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 WhitespaceMarkers rendering for edge whitespace and enhance whitespace sentinel rendering for uncommon whitespace via \\uXXXX escapes.
  • 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_CHARS has no mapping”, but renderWhitespaceMarkers now renders unknown whitespace as \\uXXXX escapes. 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 \t and \n inside the inline code.

" ": { marker: "\u2423", name: "space" },
"\t": { marker: "\\t", name: "tab" },
"\n": { marker: "\\n", name: "newline" },
"\r": { marker: "\\r", name: "newline" },
Comment thread frontend/src/components/data-table/utils.ts
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Bundle Report

Changes will increase total bundle size by 226.32kB (0.91%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
marimo-esm 25.1MB 226.32kB (0.91%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: marimo-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/cells-*.js 59 bytes 704.0kB 0.01%
assets/index-*.js 3.6kB 605.9kB 0.6%
assets/index-*.css 505 bytes 362.79kB 0.14%
assets/JsonOutput-*.js 3.27kB 343.39kB 0.96%
assets/edit-*.js 1 bytes 329.61kB 0.0%
assets/add-*.js 7 bytes 192.76kB 0.0%
assets/layout-*.js -311 bytes 185.6kB -0.17%
assets/cell-*.js 3 bytes 183.15kB 0.0%
assets/reveal-*.js (New) 165.6kB 165.6kB 100.0% 🚀
assets/swiper-*.js (New) 116.4kB 116.4kB 100.0% 🚀
assets/reveal-*.css (New) 54.08kB 54.08kB 100.0% 🚀
assets/file-*.js 50 bytes 49.4kB 0.1%
assets/panels-*.js 6 bytes 45.36kB 0.01%
assets/session-*.js -9 bytes 24.99kB -0.04%
assets/state-*.js 46 bytes 24.45kB 0.19%
assets/home-*.js 132 bytes 21.86kB 0.61%
assets/purify.es-*.js 16 bytes 21.05kB 0.08%
assets/swiper-*.css (New) 15.12kB 15.12kB 100.0% 🚀
assets/run-*.js -735 bytes 9.74kB -7.02%
assets/column-*.js -659 bytes 6.53kB -9.16%
assets/mermaid-*.core-B0EhnNjP.js (New) 2.38kB 2.38kB 100.0% 🚀
assets/slide-*.js (New) 615 bytes 615 bytes 100.0% 🚀
assets/slides-*.css -15.1kB 305 bytes -98.02%
assets/slides-*.js -116.37kB 0 bytes -100.0%
assets/mermaid-*.core-Blvy2Lmj.js (Deleted) -2.38kB 0 bytes -100.0% 🗑️

Files in assets/JsonOutput-*.js:

  • ./src/components/data-table/sentinel-cell.tsx → Total Size: 3.92kB

  • ./src/components/data-table/utils.ts → Total Size: 5.99kB

  • ./src/components/data-table/columns.tsx → Total Size: 14.2kB

@Light2Dark Light2Dark requested a review from Copilot April 20, 2026 16:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_CHARS has no mapping", but the current frontend implementation renders unknown whitespace as \\uXXXX escapes. Please update this notebook text to match the actual behavior so smoke-test expectations are accurate.

Comment thread frontend/src/components/data-table/sentinel-cell.tsx
@kirangadhave kirangadhave merged commit bfa4845 into main Apr 20, 2026
48 checks passed
@kirangadhave kirangadhave deleted the kg/whitespace-markers branch April 20, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In the table viewer, visually distinguish leading and trailing whitespace characters

4 participants