fix(web): a markdown table column no longer shrinks to one letter per line

Rendered markdown sets `overflow-wrap: anywhere` so that a long path in
prose wraps, and table cells inherited it. With `anywhere`, the browser
counts every letter as a break point when it computes a cell's minimum
width. The header cells never wrap, so in a table whose headers fill the
width, the column under an empty header got only its minimum width, and
its labels stood one letter per line.

Table cells now use `overflow-wrap: break-word`. A cell still breaks a
word that is wider than its column, but its minimum width is its longest
word. In Chromium, the label column of a five-column table went from
36 px to 74 px and wraps between words. A table with an unbreakable
cell wider than the view scrolls sideways inside its wrapper, which the
wrapper already allows.

The Response Viewer and the File Viewer's markdown view share these
rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Michael GrundbergandClaude Opus 5.5 committed 2026-11-30 13:01:47 +01:00
1 parent 6db166f3f8
commit 2ea593c2e2
2 files changed
+50

No files matched your search

+5
View File
@@ -14119,6 +14119,11 @@ html:is([data-skin="paper-gray"], [data-skin="solarized-light"], [data-skin="cat
text-align: start;
vertical-align: top;
white-space: normal;
/* A cell breaks a word only when the word alone is wider than the column. The `anywhere`
that cells inherit from .rv-text also lets the table count every letter as a break
point when it sizes its columns, so a column beside wide headers shrank to one letter
per line. */
overflow-wrap: break-word;
}
.rv-text th:last-child, .rv-text td:last-child,
+45
View File
@@ -0,0 +1,45 @@
/**
* @fileoverview Table cells in rendered markdown break only words wider than their column
* (src/web/public/styles.css).
*
* Rendered markdown sets `overflow-wrap: anywhere` so that a long path in prose wraps, and
* table cells inherited it. `anywhere` also counts every letter as a break point when the
* browser computes a cell's minimum width, and the header cells never wrap. In a table
* whose headers filled the width, the column under an empty header shrank to one letter per
* line. Cells now use `break-word`, which breaks a word only when it would overflow and
* leaves the minimum width at the longest word.
*
* jsdom has no layout, so this pins the declaration. Chromium was measured on a five-column
* table when the change was made: the label column went from 36 px, one letter per line, to
* 74 px, wrapped between words.
*/
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { describe, expect, it } from 'vitest';
const css = readFileSync(resolve(import.meta.dirname, '../src/web/public/styles.css'), 'utf8');
/** The declarations of the first rule whose selector list contains `selector`. */
function ruleBody(selector: string): string {
for (const match of css.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
const selectors = match[1]
.replace(/\/\*[\s\S]*?\*\//g, '')
.split(',')
.map((s) => s.trim());
if (selectors.includes(selector)) return match[2].replace(/\/\*[\s\S]*?\*\//g, '');
}
throw new Error(`no rule for ${selector}`);
}
describe('rendered markdown table cells', () => {
it('still wraps long words in prose anywhere', () => {
expect(ruleBody('.rv-text')).toMatch(/overflow-wrap:\s*anywhere/);
});
it.each(['.rv-text td', '.rv-text th', '.rv-table-wrap td', '.response-viewer-body > table td'])(
'%s breaks a word only when the word overflows',
(selector) => {
expect(ruleBody(selector)).toMatch(/overflow-wrap:\s*break-word/);
}
);
});