knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
GitHub READMEs do not allow custom JavaScript code, so we cannot use HTML widgets in them. But they do allow SVG images, which can also be animated. This is file is an example README. See the source Rmd file.
First we need to initialize the asciicast engine, as usual:
```r`r ''` asciicast::init_knitr_engine() ```
options(asciicast_theme = "asciinema") asciicast::init_knitr_engine()
Now we are ready to include casts. The current default is to create a snapshot of the screen after the code has run:
To include a snapshot instead of an animation, the at option must be
set to "end", but that is the default currently:
```{asciicast, cache = TRUE}`r ''`
# This is an asciicast example
loadedNamespaces()
```
```{asciicast, cache = TRUE}
loadedNamespaces()
## Proper ASCII casts
To use animated casts instead of screen shots, we need to set the
`at` option to `all`. We also set `end_wait` to wait five second before
restarting the animation. By default asciicast creates animated SVG files:
````
```{asciicast, cache = TRUE}`r ''`
#' Rows: 10
#' End_wait: 5
#' At: all
# This is an asciicast example
loadedNamespaces()
```{asciicast, cache = TRUE}
#' At: all
#' End_wait: 5
# This is an asciicast example
loadedNamespaces()
```
## ANSI colors
asciicast supports 256 ANSI colors, and ANSI support is automatically
enabled in the asciicast subprocess:
``{asciicast, cache = TRUE}r ''`
cli::ansi_palette_show()
````
```{asciicast, cache = TRUE}
cli::ansi_palette_show()
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.