{"id":14068527,"url":"https://github.com/r-lib/downlit","last_synced_at":"2025-04-07T06:04:04.258Z","repository":{"id":37074693,"uuid":"267659991","full_name":"r-lib/downlit","owner":"r-lib","description":"Syntax Highlighting and Automatic Linking","archived":false,"fork":false,"pushed_at":"2024-09-28T18:46:23.000Z","size":1886,"stargazers_count":89,"open_issues_count":37,"forks_count":22,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-31T05:01:42.345Z","etag":null,"topics":["r","syntax-highlighting"],"latest_commit_sha":null,"homepage":"https://downlit.r-lib.org","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/r-lib.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","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}},"created_at":"2020-05-28T18:00:36.000Z","updated_at":"2025-03-22T08:13:13.000Z","dependencies_parsed_at":"2023-01-21T00:16:17.834Z","dependency_job_id":"6a36b5d2-bbae-40f4-815b-5b29d5aa1120","html_url":"https://github.com/r-lib/downlit","commit_stats":{"total_commits":240,"total_committers":15,"mean_commits":16.0,"dds":0.1333333333333333,"last_synced_commit":"cf5a702106e8260d2f678b80d75835fe84f66693"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fdownlit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fdownlit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fdownlit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fdownlit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r-lib","download_url":"https://codeload.github.com/r-lib/downlit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601447,"owners_count":20964864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["r","syntax-highlighting"],"created_at":"2024-08-13T07:06:14.508Z","updated_at":"2025-04-07T06:04:04.235Z","avatar_url":"https://github.com/r-lib.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"# downlit\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/r-lib/downlit/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/downlit/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/r-lib/downlit/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/downlit?branch=main)\n[![CRAN status](https://www.r-pkg.org/badges/version/downlit)](https://CRAN.R-project.org/package=downlit)\n\u003c!-- badges: end --\u003e\n\nThe goal of downlit is to provide syntax highlighting and automatic linking of R code in a way that is easily used from RMarkdown packages like [pkgdown](https://pkgdown.r-lib.org/), [bookdown](https://bookdown.org), and [hugodown](https://hugodown.r-lib.org/).\n\n## Installation\n\nInstall downlit from CRAN with:\n\n```r\ninstall.packages(\"downlit\")\n```\n\n## Features\n\ndownlit has two slightly different highlighting/linking engines:\n\n* `highlight()` works with multiline code blocks and does syntax highlighting,\n  function linking, and comment styling.\n* `autolink()` works with inline code and only does linking.\n\nMultiline code blocks have:\n\n* Code syntax highlighted using R's parser.\n* Function calls automatically linked to their corresponding documentation.\n* Comments styled by transforming ANSI escapes sequences to their HTML \n  equivalents (thanks [fansi](https://github.com/brodieG/fansi) package).\n\nThe following forms of inline code are recognized and automatically linked:\n\n* `fun()`, `pkg::fun()`.\n* `?fun`, `pkg::fun`, `type?topic`.\n* `help(\"fun\")`, `help(\"fun\", package = \"package\")`, `help(package = \"package\")`.\n* `vignette(\"name\")`, `vignette(\"name\", package = \"package\")`.\n* `library(package)`, `require(package)`, `requireNamespace(\"package\")`.\n* `{package}` gets linked (if possible) _and formatted as plain text_. \n\n### Cross-package links\n\nIf downlit can find a pkgdown site for the remote package, it will link to it; otherwise it will link to \u003chttps://rdrr.io/\u003e for documentation, and CRAN for vignettes. In order for a pkgdown site to be findable, it needs to be listed in two places:\n\n*   In the `URL` field in the `DESCRIPTION`, as in\n    [dplyr](https://github.com/tidyverse/dplyr/blob/85faf79c1fd74f4b4f95319e5be6a124a8075502/DESCRIPTION#L15):\n  \n    ```\n    URL: https://dplyr.tidyverse.org, https://github.com/tidyverse/dplyr\n    ```\n\n*   In the `url` field in `_pkgdown.yml`, as in \n    [dplyr](https://github.com/tidyverse/dplyr/blob/master/_pkgdown.yml#L1)\n    \n    ```yaml\n    url: https://dplyr.tidyverse.org\n    ```\n    \n    When this field is defined, pkgdown generates a public facing\n    [`pkgdown.yml` file](https://dplyr.tidyverse.org/pkgdown.yml) that \n    provides metadata about the site:\n    \n    ```yaml\n    pandoc: '2.2'\n    pkgdown: 1.3.0\n    pkgdown_sha: ~\n    articles:\n      compatibility: compatibility.html\n      dplyr: dplyr.html\n    urls:\n      reference: https://dplyr.tidyverse.org/reference\n      article: https://dplyr.tidyverse.org/articles\n    ```\n\nSo when you build a pkgdown site that links to the dplyr documentation (e.g., `dplyr::mutate()`), pkgdown looks first in dplyr's `DESCRIPTION` to find its website, then it looks for `pkgdown.yml`, and uses the metadata to generate the correct links.\n\n## Usage\n\ndownlit is designed to be used by other packages, and I expect most uses of downlit will use it via another package (e.g. [hugodown](https://github.com/r-lib/hugodown)). If you want to use it in your own package, you'll typically want to apply it as part of some bigger transformation process. You can get some sense of how this might work by reading the source code of [`downlit_html()`](https://github.com/r-lib/downlit/blob/master/R/downlit-html.R) and [`downlit_md()`](https://github.com/r-lib/downlit/blob/master/R/downlit-md.R), which transform HTML and markdown documents respectively.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Fdownlit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr-lib%2Fdownlit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Fdownlit/lists"}