MyNixOS website logo
Description

Wrap Vectors in Markdown Formatting.

Ease the transition between R vectors and markdown text. With 'gluedown' and 'rmarkdown', users can create traditional vectors in R, glue those strings together with the markdown syntax, and print those formatted vectors directly to the document. This package primarily uses GitHub Flavored Markdown (GFM), an offshoot of the unambiguous CommonMark specification by John MacFarlane (2019) <https://spec.commonmark.org/>.

gluedown

Lifecycle:experimental CRANstatus Downloads Codecov testcoverage R buildstatus

The goal of gluedown is to ease the transition from R’s powerful vectors to formatted markdown text. The package uses glue() to wrap character vectors in markdown syntax. With the knitr package, users can print the formatted vectors directly to the body of a markdown document.

Installation

Install the release version from CRAN:

install.packages("gluedown")

The development version can be installed from GitHub:

# install.packages("remotes")
remotes::install_github("k5cents/gluedown")

Usage

library(gluedown)
library(stringr)
library(rvest)

Use the results='asis' chunk option to print the formatted output to the body of a document.

```{r results='asis'}
md_order(x = c("Legislative", "Executive", "Judicial"))
```
  1. Legislative
  2. Executive
  3. Judicial

Lists

Printing vectors as markdown lists was the initial inspiration for the package. Here, we use five different functions to create five elements of a new vector.

inlines <- c(
  md_bold("Alabama"),
  md_code("Alaska"),
  md_link("Arizona" = "https://az.gov"),
  md_italic("Arkansas"),
  md_strike("California")
)
print(inlines)
#> [1] "**Alabama**"               "`Alaska`"                 
#> [3] "[Arizona](https://az.gov)" "_Arkansas_"               
#> [5] "~~California~~"

Then we can print that new vector as a list, including the inline formatting.

md_bullet(inlines)
  • Alabama
  • Alaska
  • Arizona
  • Arkansas
  • California

Inline

You can also use gluedown to format R inline code results.

name <- sample(state.name, size = 1)
abb <- state.abb[match(name, state.name)]
# `r md_bold(name)`
# `r md_italic(abb)`

In this case, our randomly selected state is Texas, which has the abbreviation TX.

Pipes

All functions are designed to fit within the tidyverse ecosystem and work with pipes.

read_html("https://w.wiki/A58") %>% 
  html_node("blockquote") %>% 
  html_text(trim = TRUE) %>% 
  str_remove("\\[.*\\]") %>% 
  md_quote()

We the People of the United States, in Order to form a more perfect Union, establish Justice, insure domestic Tranquility, provide for the common defence, promote the general Welfare, and secure the Blessings of Liberty to ourselves and our Posterity, do ordain and establish this Constitution for the United States of America.

Extensions

The package primarily uses GitHub Flavored Markdown, with support for useful extensions like task lists.

legislation <- c("Houses passes", "Senate concurs", "President signs")
md_task(legislation, check = 1:2)
  • [x] Houses passes
  • [x] Senate concurs
  • [ ] President signs

Contribute

Please note that the gluedown project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Metadata

Version

1.0.9

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows