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

Abierto Apto para principiantes
#1,135 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
1/5
Tiempo estimado
Menos de una hora
Aptitud para principiantes
88/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust
Área
cli

Línea de trabajo

Lee crates/quarto/src/commands/render.rs, especialmente la comprobación existente de NO_COLOR y del terminal de stderr cerca de la línea 632, y la llamada de formato de diagnósticos cerca de la línea 1442. Pasa la decisión existente sobre el terminal y el color a format_render_diagnostics_text en lugar de activar el color de forma fija. Reproduce el problema con los pasos proporcionados NO_COLOR=1 q2 render index.qmd; se considera terminado cuando los diagnósticos no contienen secuencias de escape de color ni OSC 8 si NO_COLOR está definido o stderr está redirigido.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
Rust
Estrellas
302
Forks
22
Merge medio
5 h 6 min
PR fusionados (30 d)
207

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de quarto-dev/q2

Todos los issues de quarto-dev/q2

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.