Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions assets/styles/claude.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
body,
html
):not(
[style*="font-"],
[style*="font-"] *,
:is([style*="font-family" i], [style*="font:" i]),
:is([style*="font-family" i], [style*="font:" i]) *,
pre,
pre *,
code,
Expand Down Expand Up @@ -109,7 +109,16 @@
--fontara-claude-message-fallback: var(--fontara-claude-anthropic-sans-ui-fallback);
}

:is(article, [data-test-render-count], .font-claude-message, [role="article"], [class*="font-user-message"]) :where(
:is(
.standard-markdown,
[class*="_blocks_"],
[data-cds="Prose"],
article,
[data-test-render-count],
.font-claude-message,
[role="article"],
[class*="font-user-message"]
) :where(
p,
span,
div,
Expand All @@ -126,8 +135,8 @@
legend,
[role="heading"]
):not(
[style*="font-"],
[style*="font-"] *,
:is([style*="font-family" i], [style*="font:" i]),
:is([style*="font-family" i], [style*="font:" i]) *,
pre,
pre *,
code,
Expand Down
60 changes: 36 additions & 24 deletions tests/browser/injection-regressions.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -894,8 +894,17 @@ test("Chrome chatbot font rules preserve code, math and nested symbol fonts", as
await withRuntimePage(context, async (page) => {
for (const site of ["chatgpt", "claude", "gemini"]) {
const css = readFileSync(`assets/styles/${site}.css`, "utf8")
const result = await page.evaluate((css) => {
document.body.innerHTML = `
const result = await page.evaluate(
(css, site) => {
if (site !== "gemini") {
document.body.setAttribute(
"style",
"--font-ui-size: 16px; --text-4xl: 36px;"
)
} else {
document.body.removeAttribute("style")
}
document.body.innerHTML = `
<style>
:root { --fontara-font: "FontaraTest"; }
.code-font, .code-font code { font-family: "CodeFont"; }
Expand All @@ -916,28 +925,31 @@ test("Chrome chatbot font rules preserve code, math and nested symbol fonts", as
<span style='font-family: "AuthoredFont"'><span id="authored-font">special text</span></span>
</article>
`
const style = document.createElement("style")
style.textContent = css
document.head.appendChild(style)
const families = Object.fromEntries(
[
"text",
"user-text",
"code-font",
"math-font",
"role-math-font",
"symbol-font",
"icon-font",
"hidden-font",
"authored-font"
].map((id) => [
id,
getComputedStyle(document.getElementById(id)).fontFamily
])
)
style.remove()
return families
}, css)
const style = document.createElement("style")
style.textContent = css
document.head.appendChild(style)
const families = Object.fromEntries(
[
"text",
"user-text",
"code-font",
"math-font",
"role-math-font",
"symbol-font",
"icon-font",
"hidden-font",
"authored-font"
].map((id) => [
id,
getComputedStyle(document.getElementById(id)).fontFamily
])
)
style.remove()
return families
},
css,
site
)
assert.match(result.text, /FontaraTest/, site)
if (site === "claude") {
assert.match(result.text, /Anthropic Serif/)
Expand Down
Loading