QuartoNotebookRunner.jl icon indicating copy to clipboard operation
QuartoNotebookRunner.jl copied to clipboard

Make `--color=yes` the default for workers

Open MHellmund opened this issue 11 months ago • 8 comments

 ```{julia}
 printstyled(1/7, bold=true, color=:green, reverse=true)
 ```

doesn't work as expected. It is not enough to set color=true in IOCapture.capture(), see https://github.com/JuliaDocs/IOCapture.jl/blob/874d47adccbf49708e43f2fcc9329695203846cb/src/IOCapture.jl#L112

This patch https://github.com/MHellmund/QuartoNotebookRunner.jl/commit/9609377303cbc8061e8737012d48fd1c81801f50 works but is probably not the best way to go. Perhaps a modified version of IOCapture, also providing separate cells for stdout and stderr?

MHellmund avatar Mar 17 '24 21:03 MHellmund

Hi @MHellmund, worker processes that run the notebooks don't get passed the color arg by default. We can consider changing that default if that's what users will prefer. What does the output look like when setting

---
julia:
    exeflags: ["--color=yes"]
---

```{julia}
printstyled(1/7, bold=true, color=:green, reverse=true)
```

Can you provide the output .ipynb result of that cell? We don't of course handle the quarto render part of rendering in this repo.

MichaelHatherly avatar Mar 18 '24 09:03 MichaelHatherly

Ah, you are absolutely right! Coloring works with exeflags: ["--color=yes"] and that is fine. I did look into the documentation of Malt.jl but not into the source code :-) Please close this issue.

MHellmund avatar Mar 18 '24 10:03 MHellmund

seems reasonable to make --color=yes a default flag I would say

jkrumbiegel avatar Mar 19 '24 12:03 jkrumbiegel

seems reasonable to make --color=yes a default flag I would say

Initially, I thought about including a fix for this issue in #73. But I started to question whether --color=yes is a good default setting when I remembered how cumbersome it was to parse log messages with colorized output in another project. Probably that's not a common thing to do in a qmd file but it made me wonder if there are any other negative implications.

devmotion avatar Mar 19 '24 23:03 devmotion

Just a note: As far as I know, Quarto keeps (i.e., converts to HTML spans with color attributes) the ANSI sequences in output cells only for HTML based output formats. For other formats like PDF/LaTeX, they are, alas, filtered out at some stage by the Quarto/Pandoc system.

MHellmund avatar Mar 20 '24 11:03 MHellmund

For other formats like PDF/LaTeX, they are, alas, filtered out at some stage by the Quarto/Pandoc system.

Yeah, a bit unfortunate that that happens.

MichaelHatherly avatar Mar 20 '24 11:03 MichaelHatherly

Probably that's not a common thing to do in a qmd file but it made me wonder if there are any other negative implications.

Worth taking into account. Users should still be able to do --color=no if they want no colour for any particular reason.

MichaelHatherly avatar Mar 20 '24 11:03 MichaelHatherly

Users should still be able to do --color=no

The input flags overwrite each other, so one could still pass --color=no

image

jkrumbiegel avatar Mar 20 '24 11:03 jkrumbiegel