`q2 render` ignores `NO_COLOR` and prints colour codes and hyperlinks in its diagnostics

オープン 初心者向け
#1,135 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
cli

調査の方向性

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:

https://github.com/quarto-dev/q2/blob/8f17e950d26c68daae6e794c5fa513a96c0dae68/crates/quarto/src/commands/render.rs#L632-L638

The diagnostics themselves are printed with colour hard-coded to true:

https://github.com/quarto-dev/q2/blob/8f17e950d26c68daae6e794c5fa513a96c0dae68/crates/quarto/src/commands/render.rs#L1442-L1445

That flag drives both the colours and the OSC 8 file links:

https://github.com/quarto-dev/q2/blob/8f17e950d26c68daae6e794c5fa513a96c0dae68/crates/quarto/src/commands/render.rs#L1740-L1742

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), and q2 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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

quarto-dev/q2 のほかの issue

quarto-dev/q2 の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。