---
title: "Introduction to {blogsnip}"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{intro}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = ""
)
```
# Purpose
{blogsnip} is a small, personal collection of functions that make it easier for me to write my {blogdown} posts for [rostrum.blog](https://www.rostrum.blog){target="_blank"} in R Markdown. They generally insert code snippets or modify strings highlighted by the user.
{blogsnip} is designed to operate as an [RStudio Addin](https://rstudio.github.io/rstudioaddins/){target="_blank"}. This means its functions can be accessed from the dedicated Addins dropdown menu in the RStudio GUI and each can be mapped to a keyboard shortcut.
I later learned about--and can definitely recommend--[ThinkR's {remedy} package](https://github.com/ThinkR-open/remedy){target="_blank"} for inserting other, basic R Markdown snippets.
# Install
{blogsnip} isn't on CRAN and it probably never will be. Install from GitHub with {remotes}.
```{r eval=FALSE}
# install.packages("remotes")
remotes::install_github("matt-dray/blogsnip")
```
The {blogsnip} functions will then appear in the 'BLOGSNIP' section of the 'Addins' menu of RStudio. Restart RStudio if they don't appear immediately.
# Functions
This is a list of functions available from {blogsnip}. You can [see the source on GitHub](https://github.com/matt-dray/blogsnip/blob/master/R/blogsnip-helpers.R){target="_blank"}.
Some functions are designed to insert code snippets and others to modify selected text.
| Name | Purpose | Before | After |
| :-- | :-- | :-- | :-- |
| Insert Details | Inserts at the cursor position an expandable HTML details block. | [blank] | `
`Click for details
`
`Text goes here
`
`Session info
`
```` ```{r sessioninfo, echo=FALSE}` ````
`sessioninfo::session_info()`
```` ``` ````
`
`blogdown::shortcode("tweet", "1186758761249157122")`
```` ``` ```` |
| Insert Accessible Image | Inserts at the cursor position some HTML image code that has caption and alt text elements. | [blank] | `