`q2 render` ignores `NO_COLOR` and prints colour codes and hyperlinks in its diagnostics
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
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分
- マージ済み PR(30日)
- 207
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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
-
backlog priority: low ui
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
storytold/vectorcraft#6445 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area: cli kind:docs priority: P3
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
tursodatabase/libsql#2312 ·
メンテナーはふだん 11 日以内に返信
-
`NodeOwned::size_in_bytes` does not count the `ChildrenNodesOwned` heap allocation (since #216)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
paritytech/trie#251 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信