GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(web): add opt-in rendering for TeX equations by TheAnimatrix · Pull Request #18202 · pingdotgg/t3code

feat(web): add opt-in rendering for TeX equations #18202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TheAnimatrix wants to merge 11 commits into pingdotgg:main from TheAnimatrix:feat/render-chat-math
+1,506 −30
Closed

feat(web): add opt-in rendering for TeX equations #18202

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit Hold shift + click to select a range
0d4aee4
feat(web): add opt-in rendering for TeX equations
TheAnimatrix Oct 8, 2026
5853826
fix(web): preserve file links containing rendered math when copying
TheAnimatrix Oct 8, 2026
83c1993
fix(web): keep math source stable when loading, copying, and citing
TheAnimatrix Oct 8, 2026
692c984
Merge remote-tracking branch 'origin/main' into feat/render-chat-math
TheAnimatrix Oct 8, 2026
29313e6
Merge remote-tracking branch 'origin/main' into feat/render-chat-math
TheAnimatrix Oct 8, 2026
992edb9
feat(web): accept $$ display fences and simplify math wiring
TheAnimatrix Oct 8, 2026
9bda800
fix(web): run an unclosed display block to the end of its container
TheAnimatrix Oct 8, 2026
f487974
Merge remote-tracking branch 'origin/main' into feat/render-chat-math
TheAnimatrix Oct 11, 2026
71bc695
test(web): stub computed styles for KaTeX's MathML in jsdom
TheAnimatrix Oct 11, 2026
3d2d9b8
Merge remote-tracking branch 'origin/main' into feat/render-chat-math
TheAnimatrix Oct 11, 2026
1587811
Merge branch 'main' into feat/render-chat-math
TheAnimatrix Oct 12, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
fix(web): preserve file links containing rendered math when copying
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@TheAnimatrix
TheAnimatrix committed Oct 8, 2026
commit 58538268ddf577ee4c101c7bef54660a6bdab77e

There are no files selected for viewing

45 changes: 45 additions & 0 deletions 45 apps/web/src/components/ChatMarkdown.test.tsx
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,51 @@ describe("ChatMarkdown math", () => {
});
});

it("copies a file link with math in its label as the link, its label text as text, and the formula as TeX", async () => {
settingsOverrides.mathRenderingEnabled = true;
const view = await renderMath("See [Report \\(x\\) notes](/tmp/project/src/main.ts).");
try {
const link = view.container.querySelector('[data-markdown-copy^="[Report"]')!;
const copy = (select: (range: Range) => void) => {
const range = document.createRange();
select(range);
const selection = { rangeCount: 1, getRangeAt: () => range } as unknown as Selection;
return chatMarkdownClipboardPayload(selection);
};

const label = copy((range) => range.selectNodeContents(link.firstChild!));
expect(label?.text).toBe("Report");
expect(label?.html).not.toContain("<code>");

const whole = copy((range) => range.selectNode(link));
expect(whole?.text).toBe("[Report \\(x\\) notes](/tmp/project/src/main.ts)");
expect(whole?.html).toContain("Report <code>\\(x\\)</code> notes");
expect(whole?.html).not.toMatch(/katex|annotation|<math/);

const formula = copy((range) => range.selectNodeContents(link.querySelector(".katex-html")!));
expect(formula?.text).toBe("\\(x\\)");
expect(formula?.html).toBe('<meta charset="utf-8"><code>\\(x\\)</code>');
} finally {
await view.unmount();
delete settingsOverrides.mathRenderingEnabled;
}
});

it("copies a table cell's file link with math in its label as its label with the TeX", async () => {
settingsOverrides.mathRenderingEnabled = true;
const view = await renderMath(
"| File |\n|---|\n| [Report \\(x\\) notes](/tmp/project/src/main.ts) |",
);
try {
expect(serializeTableElementToCsv(view.container.querySelector("table")!)).toBe(
"File\nReport \\(x\\) notes main.ts",
);
} finally {
await view.unmount();
delete settingsOverrides.mathRenderingEnabled;
}
});

it("copies table math as TeX in CSV and Markdown while ordinary cells stay as before", async () => {
settingsOverrides.mathRenderingEnabled = true;
const view = await renderMath(
Expand Down
11 changes: 6 additions & 5 deletions 11 apps/web/src/markdown-clipboard.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,15 @@ export function serializeTableElementToCsv(table: Element): string {
}

/**
* A rendered formula (`data-markdown-copy` around KaTeX's `.katex`) pastes as
* its TeX source. KaTeX's visible half is `aria-hidden` and its MathML half
* carries the TeX a second time, so neither survives into a paste target
* without the stylesheet.
* A rendered formula (`data-markdown-copy` directly around KaTeX's `.katex` or
* `.katex-display`) pastes as its TeX source. KaTeX's visible half is
* `aria-hidden` and its MathML half carries the TeX a second time, so neither
* survives into a paste target without the stylesheet. A wrapper that merely
* holds a formula, like a file link with math in its label, is not one.
*/
function mathWrapperOf(element: Element | null): Element | null {
const wrapper = element?.closest("[data-markdown-copy]") ?? null;
return wrapper?.querySelector(".katex") ? wrapper : null;
return wrapper?.querySelector(":scope > .katex, :scope > .katex-display") ? wrapper : null;
}

function mathSourceElement(wrapper: Element): Element {
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.