Skip to content

fix(MarkdownRenderer): scope yfm theme to the renderer#184

Merged
ananas7 merged 2 commits into
mainfrom
fix/yfm-style-isolation
Jun 15, 2026
Merged

fix(MarkdownRenderer): scope yfm theme to the renderer#184
ananas7 merged 2 commits into
mainfrom
fix/yfm-style-isolation

Conversation

@korvin89

@korvin89 korvin89 commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Problem

YFM theming lived in a global .yfm { ... } ruleset (src/styles/yfm.scss).
.yfm is the shared root class of @diplodoc/transform, so these AIKit
overrides were not scoped to AIKit at all — they applied to any .yfm
element on the page.

For consumers who use @diplodoc/transform directly and pull in AIKit's
chat, AIKit's CSS (loaded after the transform base CSS) won the cascade on
their own markdown. The clearest symptom is <strong> / <b>: AIKit remaps
them to its accent weight (--g-text-accent-font-weight: 600), overriding the
transform default of 700 on content AIKit never rendered. The same leak
applied to the whole --yfm-color-* remap, links, code, notes, etc.

What I hit while running the tests (and why the second commit exists)

Per the testing guidelines all Playwright tests must run through Docker
(npm run playwright:docker). Running them surfaced two issues in
playwright/run-docker-command.sh, fixed in the chore(playwright): ...
commit so the runner keeps working out of the box for everyone:

  1. docker run -it requires a TTY. In CI / non-interactive shells it
    aborts immediately with the input device is not a TTY. We now allocate
    -t only when a TTY is attached ([ -t 0 ]) and always keep -i.
    A plain string (not a bash array) holds the flag on purpose: expanding an
    empty array under set -u errors on bash < 4.4, and macOS still ships
    bash 3.2 by default — so the array variant would break local runs.

  2. --grep "a b c" matched no tests. The runner executed the command via
    bash -c "$*", which joins all arguments into one space-separated string
    and drops quoting, so a multi-word grep was split into separate words
    ("No tests found"). We now pass the command as "$@" and run it directly,
    preserving argv exactly.

korvin89 added 2 commits June 14, 2026 16:18
The yfm theming lived in a global `.yfm { ... }` ruleset. Since `.yfm` is
the shared root class of @diplodoc/transform, those overrides leaked onto
markdown that consumers render with their own transform setup — e.g.
`<strong>`/`<b>` inherited AIKit's accent weight (600) instead of the
transform default (700).

Expose the theme as a `yfm-theme` mixin and include it under the renderer's
namespaced block, so the overrides apply only to AIKit's MarkdownRenderer.
The base @diplodoc/transform CSS import stays global (standard styles,
identical for every consumer).

Add a StyleIsolation story and a test asserting that standalone `.yfm`
content keeps the transform default while AIKit content keeps its accent.
`docker run -it` aborts with "the input device is not a TTY" in CI and other
non-interactive shells. Allocate `-t` only when a TTY is attached (`[ -t 0 ]`),
keeping `-i` always. A plain string is used instead of an array because
expanding an empty array under `set -u` errors on bash < 4.4 (macOS default).

Also pass the command via `"$@"` (run directly) instead of `bash -c "$*"`,
which collapsed arguments on spaces and dropped quoting — breaking multi-word
values like `--grep "a b c"`.
@gravity-ui

gravity-ui Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

🚀 Prerelease version published!

Install this PR version:

npm i --save-dev @gravity-ui/aikit@2.5.1-beta.be39a20b3a63967ffa3f40d6c2ee75d061819c5c.0

@gravity-ui-bot

Copy link
Copy Markdown

Preview is ready.

@gravity-ui

gravity-ui Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

🎭 Component Tests Report is ready.

@korvin89 korvin89 marked this pull request as ready for review June 14, 2026 14:30
@ananas7 ananas7 added this pull request to the merge queue Jun 15, 2026
Merged via the queue into main with commit 48ac1c1 Jun 15, 2026
8 checks passed
@ananas7 ananas7 deleted the fix/yfm-style-isolation branch June 15, 2026 10:40
@gravity-ui gravity-ui Bot mentioned this pull request Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants