Set `cli.num_colors = 256^3` when highlighting examples
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 62/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- r
- Domain
- documentation
Research direction
The option is set in highlight_examples() in R/highlight.R, around lines 17-22, where cli.num_colors is fixed to 256. Read that function and check how its value reaches the example output. Done means the option is set to the value the issue proposes, and the example highlighting tests still pass. Confirm first with the maintainers that 256^3 is an acceptable value, since the issue leaves that open.
Written by the indexing model from the issue text.
Description
In my package, I export a print_color() function that uses cli to print colors in the console. On the pkgdown reference page for print_color() on GitHub Pages, the output in the Examples section is being reduced to just 256 colors, even though this HTML destination should naturally support 256^3 ≈ 16.7 million colors.
I think this happens because pkgdown's highlight_examples() function sets the option cli.num_colors to 256:
https://github.com/r-lib/pkgdown/blob/f69b62a7e74b58b42170284b6f3f56c674e7a3f8/R/highlight.R#L17-L22
Could you please consider setting cli.num_colors to 256^3 instead?
Actually, I worked around this issue for my package by having print_color() read a new global option which, if non-null, is used to override cli.num_colors. Then I edited .github/workflows/pkgdown.yaml to set my new global option to 256^3 in ~/.Rprofile. That worked, but it took a lot of trial and error for me (a non-expert in package development and GitHub Actions) to get there.
Thanks for your consideration.
- Dominant language
- R
- Stars
- 776
- Forks
- 359
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from r-lib/pkgdown
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
favicons fallback on raster.png due to smart quote in inst/BS5/templates/head.htmlPossibly taken @njtierney claimed this 108 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Oversized ROR logo with bootstrap: 3Possibly taken @Bisaloo claimed this 112 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Tests error instead of skipping when optional packages (ecmwfr, jsonvalidate) or BETY database are unavailablePossibly taken @madhavzanwar claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
PecanProject/pecan#4179 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Huber-group-EMBL/Rarr#261 ·
Maintainers usually reply within 1 day