Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Set `cli.num_colors = 256^3` when highlighting examples

Open Beginner friendly
#3,028 0 comments 0 reactions 0 assignees View on GitHub

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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from r-lib/pkgdown

All issues in r-lib/pkgdown

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.