Public: anyone can read this; the crew can change it.

`.tok-plain` leaves the stylesheet: the highlighter never writes it #5270

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/5259-tok-plain-leaves-the-stylesheet-the-high → main 1 commit fork

  • Merged. scout/5259-tok-plain-leaves-the-stylesheet-the-high was merged into main as 220f9c5.

Review

Sign in to review this change.
3 files changed +8 −3
docs/DESIGN.md −1
@@ -545,7 +545,6 @@ the same line (#4888).
545545 - `.tok-meta`
546546 - `.tok-number`
547547 - `.tok-operator`
548 - `.tok-plain`
549548 - `.tok-property`
550549 - `.tok-punctuation`
551550 - `.tok-regex`
src/web/style/content.ts −1
@@ -383,7 +383,6 @@ form.inline { display: inline; margin-left: auto; }
383383 .tok-type { color: var(--tok-type); }
384384 .tok-constant { color: var(--tok-constant); }
385385 .tok-meta { color: var(--tok-meta); }
386 .tok-plain { color: inherit; }
387386 /* Punctuation and operators sit *below* the text colour on purpose: they are
388387 the scaffolding of a line, and colouring them loudly makes code shout. */
389388 .tok-operator { color: var(--tok-operator); }
test/highlight.test.ts +8 −1
@@ -28,7 +28,7 @@ import {
2828 type Language,
2929 type Token,
3030 } from "../src/web/highlight.ts";
31 import { renderTokens, tokenClasses } from "../src/web/highlight-html.ts";
31 import { highlightToLines, renderTokens, tokenClasses } from "../src/web/highlight-html.ts";
3232 import { THEMES, THEME_NAMES } from "../src/design/themes.ts";
3333 import { css } from "../src/web/style.ts";
3434
@@ -798,6 +798,13 @@ describe("token vocabulary", () => {
798798 if (t.kind) emitted.add(`tok-${t.kind}`);
799799 }
800800
801 test("plain text gets no tok-plain class and the stylesheet has no rule for it", () => {
802 const html = highlightToLines("foo bar", "ts").join("\n");
803 expect(html).toContain("foo");
804 expect(html).not.toContain("tok-plain");
805 expect(css).not.toContain(".tok-plain");
806 });
807
801808 test("every class the fixtures emit has a stylesheet rule", () => {
802809 for (const name of emitted) {
803810 if (name === "tok-plain") continue;

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs