Generate a hugo shortcode with appropriate pandoc markup to preserve it as is when embedded in an R markdown document.

Generally, I don't recommend calling this function directly; instead use it inside a function with the same name as the shortcode you want to wrap. See embed_gist() and friends for examples

shortcode(
  .name,
  ...,
  .contents = NULL,
  .output = c("html", "md"),
  .inline = FALSE
)

Arguments

.name

Name of the shortcode

...

Arguments to the shortcode, supplied either by name or position depending on the shortcode. By default, strings will automatically be quoted with single quotes. Suppress this quoting by wrapping the argument in I().

.contents

Contents of the shortcode for paired shortcodes.

.output

Is the output of the shortcode html or markdown? This controls whether the shortcode uses <> or %.

.inline

Is the shortcode designed to be used inline or in its own paragraph? Controls whether the shortcode is wrapped in a block or inline raw attribute.

Examples

pkg <- function(name) {
  shortcode("pkg", name, .inline = TRUE)
}
pkg("hugodown")
#> [1] "`{{< pkg 'hugodown' >}}`{=html}"