All Projects → r-lib → Downlit

r-lib / Downlit

Licence: other
Syntax Highlighting and Automatic Linking

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to Downlit

Bat
A cat(1) clone with wings.
Stars: ✭ 30,833 (+78958.97%)
Mutual labels:  syntax-highlighting
Asciidoc Kate
AsciiDoc/AsciiDoctor syntax highlighting plugin for Kate editor/KatePart
Stars: ✭ 5 (-87.18%)
Mutual labels:  syntax-highlighting
Illuminate Js
Syntax Highlighter made for and in ES6. Works both on Node and Browser (React too!).
Stars: ✭ 26 (-33.33%)
Mutual labels:  syntax-highlighting
Matlab Schemer
Apply and save color schemes in MATLAB with ease.
Stars: ✭ 708 (+1715.38%)
Mutual labels:  syntax-highlighting
Rsyntaxtextarea
A syntax highlighting, code folding text editor for Java Swing applications.
Stars: ✭ 767 (+1866.67%)
Mutual labels:  syntax-highlighting
Sublimetext
Caddyfile syntax highlighting for Sublime Text 3
Stars: ✭ 17 (-56.41%)
Mutual labels:  syntax-highlighting
Pdbpp
pdb++, a drop-in replacement for pdb (the Python debugger)
Stars: ✭ 693 (+1676.92%)
Mutual labels:  syntax-highlighting
Syntect
Rust library for syntax highlighting using Sublime Text syntax definitions.
Stars: ✭ 972 (+2392.31%)
Mutual labels:  syntax-highlighting
Imguicolortextedit
Colorizing text editor for ImGui
Stars: ✭ 772 (+1879.49%)
Mutual labels:  syntax-highlighting
Npp Robot
📝 Notepad++ syntax highligher for Robotframework automation framework
Stars: ✭ 25 (-35.9%)
Mutual labels:  syntax-highlighting
Codeview Android
Display code with syntax highlighting ✨ in native way.
Stars: ✭ 748 (+1817.95%)
Mutual labels:  syntax-highlighting
Semshi
🌈 Semantic Highlighting for Python in Neovim
Stars: ✭ 758 (+1843.59%)
Mutual labels:  syntax-highlighting
New Moon
🌙 ‎ The optimized dark theme for web development.
Stars: ✭ 918 (+2253.85%)
Mutual labels:  syntax-highlighting
Gatsby Gitbook Starter
Generate GitBook style modern docs/tutorial websites using Gatsby + MDX
Stars: ✭ 700 (+1694.87%)
Mutual labels:  syntax-highlighting
Vscode Smarty
Smarty syntax highlight extension for Visual Studio Code
Stars: ✭ 10 (-74.36%)
Mutual labels:  syntax-highlighting
Rich
Rich is a Python library for rich text and beautiful formatting in the terminal.
Stars: ✭ 31,664 (+81089.74%)
Mutual labels:  syntax-highlighting
6502 Npp Syntax
Notepad++ Syntax Highlighting for 6502 Assembly (and NESASM)
Stars: ✭ 17 (-56.41%)
Mutual labels:  syntax-highlighting
Highr
Syntax Highlighting for R Source Code
Stars: ✭ 36 (-7.69%)
Mutual labels:  syntax-highlighting
Prettify Matlab
MATLAB syntax highlighting for google-code-prettify
Stars: ✭ 10 (-74.36%)
Mutual labels:  syntax-highlighting
Clygments
🎨 Code highlighting using Pygments in Clojure
Stars: ✭ 22 (-43.59%)
Mutual labels:  syntax-highlighting

downlit

R build status Codecov test coverage CRAN status

The 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, bookdown, and hugodown.

Installation

Install downlit from CRAN with:

install.packages("downlit")

Features

downlit has two slightly different highlighting/linking engines:

  • highlight() works with multiline code blocks and does syntax highlighting, function linking, and comment styling.
  • autolink() works with inline code and only does linking.

Multiline code blocks have:

  • Code syntax highlighted using R's parser.
  • Function calls automatically linked to their corresponding documentation.
  • Comments styled by transforming ANSI escapes sequences to their HTML equivalents (thanks fansi package).

The following forms of inline code are recognized and automatically linked:

  • fun(), pkg::fun().
  • ?fun, pkg::fun, type?topic.
  • help("fun"), help("fun", package = "package"), help(package = "package").
  • vignette("name"), vignette("name", package = "package").
  • library(package), require(package), requireNamespace("package").
  • {package} gets linked (if possible) and formatted as plain text.

Cross-package links

If downlit can find a pkgdown site for the remote package, it will link to it; otherwise it will link to https://rdrr.io/ for documentation, and CRAN for vignettes. In order for a pkgdown site to be findable, it needs to be listed in two places:

  • In the URL field in the DESCRIPTION, as in dplyr:

    URL: https://dplyr.tidyverse.org, https://github.com/tidyverse/dplyr
    
  • In the url field in _pkgdown.yml, as in dplyr

    url: https://dplyr.tidyverse.org
    

    When this field is defined, pkgdown generates a public facing pkgdown.yml file that provides metadata about the site:

    pandoc: '2.2'
    pkgdown: 1.3.0
    pkgdown_sha: ~
    articles:
      compatibility: compatibility.html
      dplyr: dplyr.html
    urls:
      reference: https://dplyr.tidyverse.org/reference
      article: https://dplyr.tidyverse.org/articles
    

So 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.

Usage

downlit is designed to be used by other packages, and I expect most uses of downlit will use it via another package (e.g. 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() and downlit_md(), which transform HTML and markdown documents respectively.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].