Skip to content

fix(react): style verbatim via CSS, not an inline gray code block - #34

Merged
pyramation merged 2 commits into
mainfrom
fix-verbatim-css
Aug 24, 2026
Merged

fix(react): style verbatim via CSS, not an inline gray code block#34
pyramation merged 2 commits into
mainfrom
fix-verbatim-css

Conversation

@pyramation

Copy link
Copy Markdown
Collaborator

Moves the verbatim styling out of the React component's inline style and into latex2js.css.

Problem

latex2react's verbatim component hardcoded backgroundColor: #f5f5f5 + 10px padding + 4px radius, so every consumer got a gray code block regardless of page background, and sites could only override it with !important (the latex2js.com/mathapedia.com sites both had to do exactly that).

Change

  • verbatim.tsx renders just <pre className="verbatim"> — no inline style.
  • latex2js.css (source in @mathapedia/css + shipped copy) now defines the default:
    pre.verbatim { background-color: transparent; padding: 0; border-radius: 0; }
    i.e. plain, page-coloured code matching the original sites. Consumers who want a code-block look override the class normally.

This is the last inline style in the react components; nicebox/enumerate/math were already converted to lines + CSS.

The verbatim component hardcoded a gray (#f5f5f5) code-block look, so every
consumer got it regardless of page background and could only override it with
!important. Move the styling into latex2js.css as a plain, page-coloured
default (transparent, no padding/rounding) — matching the original sites —
which consumers can override with a normal rule.
pnpm build copies packages/latex2js/latex2js.css into bundle/latex2js.css;
the verbatim CSS landed in the source but the committed bundle stayed
stale, failing the 'Shipped bundle is up to date' check.
@pyramation
pyramation merged commit 46ede53 into main Aug 24, 2026
4 checks passed
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.

1 participant