{"id":33907010,"url":"https://github.com/friendly/colorize","last_synced_at":"2026-04-06T02:02:20.981Z","repository":{"id":323236959,"uuid":"1092533364","full_name":"friendly/colorize","owner":"friendly","description":"Render Text in Color for Markdown / Quarto Documents in HTML or LaTeX","archived":false,"fork":false,"pushed_at":"2025-12-16T14:56:06.000Z","size":3008,"stargazers_count":2,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-02-16T05:23:05.786Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://friendly.github.io/colorize","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/friendly.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-08T19:59:27.000Z","updated_at":"2025-12-16T14:56:09.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/friendly/colorize","commit_stats":null,"previous_names":["friendly/colorize"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/friendly/colorize","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendly%2Fcolorize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendly%2Fcolorize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendly%2Fcolorize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendly%2Fcolorize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/friendly","download_url":"https://codeload.github.com/friendly/colorize/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendly%2Fcolorize/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31456664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"online","status_checked_at":"2026-04-06T02:00:07.287Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-12T02:21:23.327Z","updated_at":"2026-04-06T02:02:20.963Z","avatar_url":"https://github.com/friendly.png","language":"R","readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n\u003c!-- badges: start --\u003e\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)\n[![Last Commit](https://img.shields.io/github/last-commit/friendly/colorize)](https://github.com/friendly/colorize/)\n\u003c!-- badges: end --\u003e\n\n\n```{r setup}\n#| echo: false\nlibrary(colorize)\n```\n\n# colorize  \n\n**Version 0.2.0**\n\n\n\u003cimg src=\"man/figures/logo.jpg\" height=\"120\" style=\"float:right; height:120px;\"/\u003e\nThe `colorize` package provides some simple functions for printing text in color in markdown or Quarto documents,\nto be rendered as HTML or LaTeX.\n\nThis is useful when writing about the use of colors in graphs or tables, where you want to print\ntheir names in their actual color to give a direct impression of the color, like \"red\" shown in `r colorize(\"red\")`, or\n\"blue\" shown in `r colorize(\"blue\")`. This is similar to the use of *direct labels* in graphs, which are perceptually bound closely\nto what is portrayed, rather than an _indirect legend_, which takes more cognitive energy to see what data in referred to\nin the graph.\n\nThe following functions are provided:\n\n* `colorize(text, color)`: Print the `text` in a given `color`, as in `r colorize(\"this text in red\", \"red\")`\n* `colorize_bg(text, color)`: Print the `text` with a background in `color`, as in `r colorize_bg(\"this text in red\", \"red\")`\n* `colorbox(text, color, ...)`: Print `text` with background in color, but where the text is given a contrasting color designed to be most legible, as in `r colorbox(\"this text in red\", \"red\")`\n\nIn the examples above, note the difference between `colorize_bg()` and `colorbox()`: when the desired color is `r colorize(\"red\")`,\n`colorbox()` uses a lighter color (white) so the text contrasts more with the darker background.\n\nThis is somewhat similar to what RStudio does when you enter color names or hex values in code, but `colorbox()` uses\n`colorspace::contrast_ratio(textcolor, color, ...)` to find the `textcolor` that **contrasts best** against the background `color`.\n\n![](man/figures/test_colors.png)\n\nThe uses of color for text in visualization is far more general than represented here.\nBrath (2020) is a wonderful source for inspiration!\n\n## Installation\n\n\n`colorize` is not yet on CRAN.\nYou can install the development version of colorize from either the GitHub repo or r-universe, as follows:\n\n\n``` r\nremotes::install.github(\"friendly/colorize\")\n# or:\ninstall.packages('colorize', repos = c('https://friendly.r-universe.dev'))\n```\n\nThe package vignette, `vignette(\"colorbox\", package = \"colorize\")` describes the use of these functions.\n\n## Example\n\nThis example simply shows how a set of color names is rendered in HTML encoding. It doesn't print them in their colors.\n\n```{r example}\nlibrary(colorize)\n# define some color names\n\ntest_colors \u003c- c(\"red\", \"blue\", \"green\",\n                 \"white\", \"black\", \"gray\",\n                 \"pink\", \"yellow\", \"darkgreen\")\n\nsapply(test_colors, colorize)\n```\n\n## Related\n\nFor a purely Quarto approach, [quarto-highlight-text](https://m.canouil.dev/quarto-highlight-text/)\nis a Quarto extension that allows you to highlight text in a document for various formats: HTML, LaTeX, Typst, Docx, PowerPoint, Reveal.js, and Beamer.\n \n\n## Citation\n\nIf you find this package useful in your work, you can cite it as:\n\n  Friendly M, Zeileis A (2025). _colorize: Render Text in Color for Markdown/Quarto Documents_. R package version 0.2.0,\n  \u003chttps://github.com/friendly/colorize\u003e.\n\n\n## References\n\nBrath, R. (2020). _Visualizing with Text_. A K Peters/CRC Press. https://doi.org/10.1201/9780429290565\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriendly%2Fcolorize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffriendly%2Fcolorize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriendly%2Fcolorize/lists"}