Theme compilation fails when a theme declares `$body-bg` or `$body-color` as `null`

未关闭 适合新手
#15,304 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
sass, scss
领域
build-system

调研方向

从 issue 中链接的两个检查处开始查看 src/resources/formats/html/bootstrap/_bootstrap-variables.scss,并将它们与现有的 pre-color 空值检查进行比较。使用提供的 custom.scss 和 index.qmd 示例,通过 quarto render index.qmd 重现问题。当将 $body-bg 或 $body-color 声明为 null 的主题能够使用文档中说明的回退值进行渲染时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

bootstrap bug themes
I have:
  • searched the issue tracker for similar issues
  • installed the latest version of Quarto CLI
  • formatted my issue following the Bug Reports guide
Bug description

Quarto's Bootstrap variables test variable-exists(body-bg) and variable-exists(body-color) to decide whether a theme has set them.
variable-exists() is true for a variable that holds null, so a theme that declares $body-bg: null !default; makes $body-contrast-bg null, and compilation stops.

The pre-color check a few lines above already handles this case with variable-exists(pre-color) and $pre-color != null:

A null declaration at the root is what Dart Sass itself recommends.
A theme that sets $body-bg only under some condition has to declare it first, or use !global inside the @if, which Dart Sass flags as deprecated:

DEPRECATION WARNING [new-global]: As of Dart Sass 2.0.0, !global assignments won't be able to declare new variables.

Recommendation: add `$body-bg: null` at the stylesheet root.

Following that advice breaks the render, so the theme is stuck with the deprecation.
I also tried $primary: null !default;, and that one renders.

Steps to reproduce

custom.scss:

/*-- scss:defaults --*/
$body-bg: null !default;

index.qmd:

---
title: "Null body-bg"
format:
  html:
    theme: [default, custom.scss]
---

Hello.

Run quarto render index.qmd.
Replace $body-bg with $body-color for the second error.

Actual behavior

With $body-bg: null !default;:

ERROR: Theme file compilation failed:

Error: $color: null is not a color.
    ╷
827 │   $red: _linear-channel-value(quarto-color.red($color));
    │                               ^^^^^^^^^^^^^^^^^^^^^^^^
    ╵
  ... 827:31   luminance()
  ... 837:13   quarto-contrast()
  ... 854:19   tone()
  ... 508:7    theme-contrast()

With $body-color: null !default; and the default theme:

Error: $color1: null is not a color.
Expected behavior

A null value counts as "not set", as it already does for $pre-color.
Quarto falls back to $white and $gray-900, and the document renders.

Your environment
  • IDE: none, command line.
  • OS: macOS 27.2.
Quarto check output

Reproduced with a development build of main at 089ba530b.
The two lines above are the same at the v1.11.9 tag.

Quarto 99.9.9
[✓] Checking environment information...
      Quarto cache location: /Users/mcanouil/Library/Caches/quarto
      Project: none found (single-file mode)
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.10.0: OK
      Dart Sass version 1.107.1: OK
      Deno version 2.9.8: OK
      Typst version 0.15.1: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 99.9.9
      commit: 089ba530b3ed4ec156a355d41b6b7de2db3e44ea
      Path: /Users/mcanouil/Projects/quarto-dev/quarto-cli/package/dist/bin
[✓] Checking tools....................OK
      TinyTeX: v2026.07
      Chrome Headless Shell: (not installed)
      VeraPDF: (not installed)
[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /Users/mcanouil/Library/TinyTeX/bin/universal-darwin
      Version: 2026
[✓] Checking Chrome Headless....................OK
      Using: Chrome from QUARTO_CHROMIUM
      Path: /Applications/Brave Browser.app/Contents/MacOS/Brave Browser
[✓] Checking basic markdown render....OK
主要语言
JavaScript
星标
6.1k
派生
478
平均合并
17 小时 53 分钟
30 天内合并 PR
135

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

quarto-dev/quarto-cli 的其他 Issue

查看 quarto-dev/quarto-cli 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。