Skip to content

Commit 8032ec0

Browse files
authored
Merge pull request #11389 from quarto-dev/fix/multiple-mainfont
css - don't quote fonts if already quoted
2 parents d957b3e + 20dca08 commit 8032ec0

File tree

5 files changed

+42
-5
lines changed

5 files changed

+42
-5
lines changed

src/core/css.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ export function asCssFont(value: unknown): string | undefined {
9090
.split(",")
9191
.map((font) => {
9292
font = font.trim();
93-
if (font.includes(" ")) {
93+
if (
94+
font.includes(" ") && !font.startsWith('"') && !font.startsWith("'")
95+
) {
9496
font = `"${font}"`;
9597
}
9698
return font;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: "Code font size"
3+
format: html
4+
mainfont: Creepster, "Cascadia Code", Inter
5+
---
6+
7+
# content
8+
9+
Content
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: "Code font size"
3+
format: html
4+
mainfont: Creepster, Cascadia Code, Inter
5+
---
6+
7+
# content
8+
9+
Content
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: "Code font size"
3+
format: html
4+
mainfont: Creepster, 'Cascadia Code', Inter
5+
---
6+
7+
# content
8+
9+
Content

tests/integration/playwright/tests/html-themes.spec.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { test, expect } from '@playwright/test';
2+
import { getCSSProperty } from '../src/utils';
23

34
test('Dark and light theme respect user themes', async ({ page }) => {
45
// This document use a custom theme file that change the background color of the title banner
@@ -25,8 +26,15 @@ test('Code block font size did not change and still equals to pre size', async (
2526
await page.goto('./html/code-font-size.html');
2627
const code = page.getByRole('code')
2728
const pre = page.locator('pre')
28-
const preFontSize = await pre.evaluate((element) =>
29-
window.getComputedStyle(element).getPropertyValue('font-size'),
30-
);
29+
const preFontSize = await getCSSProperty(pre, 'font-size', false) as string;
3130
await expect(code).toHaveCSS('font-size', preFontSize);
32-
});
31+
});
32+
33+
test('Mainfont can be set to multiple mainfont families', async ({ page }) => {
34+
await page.goto('./html/mainfont/mainfont-1.html');
35+
expect(await getCSSProperty(page.locator('body'), '--bs-body-font-family', false)).toEqual('Creepster, "Cascadia Code", Inter');
36+
await page.goto('./html/mainfont/mainfont-2.html');
37+
expect(await getCSSProperty(page.locator('body'), '--bs-body-font-family', false)).toEqual('Creepster, "Cascadia Code", Inter');
38+
await page.goto('./html/mainfont/mainfont-3.html');
39+
expect(await getCSSProperty(page.locator('body'), '--bs-body-font-family', false)).toEqual('Creepster, "Cascadia Code", Inter');
40+
})

0 commit comments

Comments
 (0)