-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Think about how to colour html output #24
Comments
Yeah, I thought about this, too, and will be happy to add whatever is needed. |
Yeah, that's on the todo list |
@yihui Any idea how this could work? I guess some support is needed from pandoc as well? Does that exist? |
I don't have a clear idea about this. Maybe it is the responsibility of evaluate (around here https://github.com/hadley/evaluate/blob/master/R/watcher.r#L32) to generate HTML spans, or maybe one can use the knitr |
It does not have to be ANSI, actually. But I think that even just passing the ANSI seqs to evaluate / knitr could work. An ANSI colored output is just a regular string, with some strange-looking markup in it, so the |
OK, I tried it. The ANSI markup goes through, so I just need an output hook that interprets it, and converts it to HTML. \o/ |
So, it works very well IMO. Here is an example: You can see the output here: What would be the best way to ship this? A function in the I think you could even turn this on by default in the default html hooks. Unfortunately AFAIK there is no way to color a markdown document, at least not with GFM. :( |
Maybe a function in crayon like |
OK, I can do that. I would turn it on by default, though. I mean, once the hooks are set, it is on, and you can turn it off with a chunk option. It would be very annoying to turn it on manually all the time, and (for HTML output), it is harmless. Btw. this approach is not very good if you have both markdown and html output, because the markdown will have the ANSI seqs, but I guess I can just add a markdown output hook to remove them. |
"Turning it on manually all the time" will be annoying if many people actually use this hook. I'm not sure this will be so popular that I need to support it "officially" (which means I'll introduce a Suggests dependency in knitr, and perhaps spend some time on maintaining this hook in the future). I like the colored terminal output, but personally I'm not very interested in colored output in HTML, so my current decision is if you want this feature, you opt in by setting the output hook. |
Well, the last thing I want is to annoy people. :) |
Are there any new thoughts on this issue? I am not sure I understand why such a hook would be annoying. I would like to use it for my own reports, but I cannot view the gist. I also posted here. |
@wlandau-lilly If you are asking me, the answer is no. I'm not interested in this feature, but knitr is open --- you don't really need my specific support. You should be able to opt in by yourself. |
@yihui I do not care where or how it is implemented, and I agree that |
I would love to have functions in |
This seems to work:
Markdown output:
I look forward to the release of ansistrings. |
While trying to understand what is going on in yihui/knitr#1805, here is an update regarding opting-in for coloured html output from crayon using The hook thing described above has not been included in crayon directly, but it has been in This is useful for preserving tidyverse coloring in output, errors and others. To render with
Hoping it will help others who want to preserve R terminal colouring. |
That is a really nice solution that @cderv provided! Thank you! One question, though: this makes the outputs to be in separate boxes.. for example, in the last example given, I would like to have both the call |
Thanks @fmmattioni ! I think this question has nothing to do with the current topic of this closed issue. Please, could you ask this question in RStudio Community ? It would be a better place to have a discussion there and I could give you an answer there. Thank you very much ! |
Hello, Does this feature work with |
@phineas-pta craoyn does not do anything towards this, so I am afraid you'll need to ask at fansi or shiny. |
It would be nice if crayon also worked inside of knitr, rmarkdown, etc.
This probably requires some thinking to ensure that things are escaped correctly. (Or maybe it's the responsibility of evaluate to turn terminal escapes into the appropriate html spans)
cc @yihui
The text was updated successfully, but these errors were encountered: