`q2 render` ignores `NO_COLOR` and prints colour codes and hyperlinks in its diagnostics
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
阅读 crates/quarto/src/commands/render.rs,尤其是第 632 行附近现有的 NO_COLOR 和 stderr 终端检查,以及第 1442 行附近的诊断格式化调用。将现有的终端和颜色判断传给 format_render_diagnostics_text,不要硬编码为启用颜色。按照提供的步骤 NO_COLOR=1 q2 render index.qmd 复现;当设置了 NO_COLOR 或 stderr 被重定向时,诊断信息不含颜色或 OSC 8 转义序列,即为完成。
由索引模型根据 Issue 内容生成。
描述
Bug description
The script I use to check the dashboard from #1131 against q2 saves each render log to a file, and those logs are full of escape sequences.
With Quarto 1, NO_COLOR=1 gives me plain logs, but q2 ignores it.
q2 render already has a test for NO_COLOR and for a terminal on stderr, and uses it for the summary line with the error and warning counts:
The diagnostics themselves are printed with colour hard-coded to true:
That flag drives both the colours and the OSC 8 file links:
Steps to reproduce
index.qmd, which includes a file that does not exist, so both tools stop with an error:
---
title: Hello
---
{{< include missing.qmd >}}
NO_COLOR=1 q2 render index.qmd 2>log
python3 -c "d = open('log').read(); print(d.count('\x1b['), d.count('\x1b]8;'))"
NO_COLOR=1 quarto render index.qmd 2>log
python3 -c "d = open('log').read(); print(d.count('\x1b['), d.count('\x1b]8;'))"
Actual behavior
| q2 | Quarto 1 | |
|---|---|---|
| stderr to a file | 162 colour sequences, 2 OSC 8 links | 2 colour sequences |
stderr to a file, NO_COLOR=1 |
162 colour sequences, 2 OSC 8 links | none |
Quarto 1 also colours a log file, but NO_COLOR turns every escape off.
In q2 it changes nothing.
Expected behavior
No escape sequences when NO_COLOR is set, as in Quarto 1, and none when stderr is not a terminal, as the summary line already does.
Passing stderr_use_color() in place of true to format_render_diagnostics_text would cover both.
Your environment
- q2:
q2 (quarto 2) 0.43.0-nightly.20261109(nightly built from 8f17e95), andq2 v0.42.0. - Quarto 1 for comparison: development build of quarto-dev/quarto-cli@fa74261.
- OS: macOS 27.2 (arm64).
- Terminal, no IDE.
- 主要语言
- Rust
- 星标
- 302
- 派生
- 22
- 平均合并
- 5 小时 6 分钟
- 30 天内合并 PR
- 207
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
quarto-dev/q2 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 73/100
quarto-dev/q2#1155 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
quarto-dev/q2#1133 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
quarto-dev/q2#1103 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
quarto-dev/q2#1095 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
quarto-dev/q2#1031 ·
维护者通常 1 天内回复
相似的 Issue
-
agent-self
难度 2/5 1-3 小时 新手友好度 84/100
yologdev/yoyo-evolve#1176 ·
-
难度 2/5 1-3 小时 新手友好度 67/100
Richard-Zhang1019/Crossbow#431 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 86/100
saschanaz/jxl-winthumb#69 ·
-
ready
难度 1/5 1 小时以内 新手友好度 88/100
TusanHomichi/PSIV#504 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复