Skip to content
Merged
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
4 changes: 3 additions & 1 deletion src/core/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export function asCssFont(value: unknown): string | undefined {
.split(",")
.map((font) => {
font = font.trim();
if (font.includes(" ")) {
if (
font.includes(" ") && !font.startsWith('"') && !font.startsWith("'")
) {
font = `"${font}"`;
}
return font;
Expand Down
9 changes: 9 additions & 0 deletions tests/docs/playwright/html/mainfont/mainfont-1.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "Code font size"
format: html
mainfont: Creepster, "Cascadia Code", Inter
---

# content

Content
9 changes: 9 additions & 0 deletions tests/docs/playwright/html/mainfont/mainfont-2.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "Code font size"
format: html
mainfont: Creepster, Cascadia Code, Inter
---

# content

Content
9 changes: 9 additions & 0 deletions tests/docs/playwright/html/mainfont/mainfont-3.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "Code font size"
format: html
mainfont: Creepster, 'Cascadia Code', Inter
---

# content

Content
16 changes: 12 additions & 4 deletions tests/integration/playwright/tests/html-themes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test';
import { getCSSProperty } from '../src/utils';

test('Dark and light theme respect user themes', async ({ page }) => {
// This document use a custom theme file that change the background color of the title banner
Expand All @@ -25,8 +26,15 @@ test('Code block font size did not change and still equals to pre size', async (
await page.goto('./html/code-font-size.html');
const code = page.getByRole('code')
const pre = page.locator('pre')
const preFontSize = await pre.evaluate((element) =>
window.getComputedStyle(element).getPropertyValue('font-size'),
);
const preFontSize = await getCSSProperty(pre, 'font-size', false) as string;
await expect(code).toHaveCSS('font-size', preFontSize);
});
});

test('Mainfont can be set to multiple mainfont families', async ({ page }) => {
await page.goto('./html/mainfont/mainfont-1.html');
expect(await getCSSProperty(page.locator('body'), '--bs-body-font-family', false)).toEqual('Creepster, "Cascadia Code", Inter');
await page.goto('./html/mainfont/mainfont-2.html');
expect(await getCSSProperty(page.locator('body'), '--bs-body-font-family', false)).toEqual('Creepster, "Cascadia Code", Inter');
await page.goto('./html/mainfont/mainfont-3.html');
expect(await getCSSProperty(page.locator('body'), '--bs-body-font-family', false)).toEqual('Creepster, "Cascadia Code", Inter');
})
Loading