diff --git a/src/resources/formats/html/bootstrap/_bootstrap-rules.scss b/src/resources/formats/html/bootstrap/_bootstrap-rules.scss index a4676bee06b..91080707da3 100644 --- a/src/resources/formats/html/bootstrap/_bootstrap-rules.scss +++ b/src/resources/formats/html/bootstrap/_bootstrap-rules.scss @@ -2150,15 +2150,26 @@ code.sourceCode a.code-annotation-anchor { // override _reboot.scss // code blocks -pre code { +pre { font-family: $font-family-monospace-block; // I'm really not confident that this is correct @include font-size($code-block-font-size); font-weight: $font-weight-monospace-block; + + // adding these inherit overrides here + // is what `_reboot.scss` does. + // we mirror it here for consistency + // + // Account for some code outputs that place code tags in pre tags + code { + font-family: inherit; + @include font-size(inherit); + font-weight: inherit; + } } // code inlines -p code { +code { font-family: $font-family-monospace-inline; @include font-size($code-inline-font-size); font-weight: $font-weight-monospace-inline; diff --git a/tests/docs/playwright/html/code-font-size.qmd b/tests/docs/playwright/html/code-font-size.qmd new file mode 100644 index 00000000000..b3bb0a94ccb --- /dev/null +++ b/tests/docs/playwright/html/code-font-size.qmd @@ -0,0 +1,8 @@ +--- +title: Testing code font size +format: html +--- + +```python +1 + 1 +``` diff --git a/tests/integration/playwright/tests/html-themes.spec.ts b/tests/integration/playwright/tests/html-themes.spec.ts index 84d53f7b866..0ecb43cf809 100644 --- a/tests/integration/playwright/tests/html-themes.spec.ts +++ b/tests/integration/playwright/tests/html-themes.spec.ts @@ -19,4 +19,14 @@ test('Dark theming toggle change to dark background ', async ({ page }) => { await page.locator("a.quarto-color-scheme-toggle").click(); const locatr2 = await page.locator('div').filter({ hasText: 'Quarto Playground' }).first() await expect(locatr2).toHaveCSS('background-color', 'rgb(255, 0, 0)'); +}); + +test('Code block font size did not change and still equals to pre size', async ({ page }) => { + 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'), + ); + await expect(code).toHaveCSS('font-size', preFontSize); }); \ No newline at end of file