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

Đang mở Phù hợp với người mới
#1,135 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
88/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
cli

Hướng nghiên cứu

Đọc crates/quarto/src/commands/render.rs, đặc biệt là phần kiểm tra NO_COLOR và terminal của stderr hiện có gần dòng 632, cùng lời gọi định dạng diagnostics gần dòng 1442. Truyền quyết định hiện có về terminal và màu sắc cho format_render_diagnostics_text thay vì luôn bật màu. Tái hiện bằng các bước được cung cấp NO_COLOR=1 q2 render index.qmd; hoàn thành khi diagnostics không có chuỗi escape màu hoặc OSC 8 khi NO_COLOR được đặt hoặc stderr được chuyển hướng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Rust
Star
302
Fork
22
Merge trung bình
5 giờ 6 phút
Pull request đã merge (30 ngày)
207

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của quarto-dev/q2

Tất cả issue của quarto-dev/q2

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.