#' Convert to MediaWiki Markup
#'
#' Format for converting from R Markdown to MediaWiki Markup.
#'
#' @param keep_md Keep the markdown file generated by knitting.
#' @param pandoc_args Additional command line options to pass to pandoc.
# nolint start
#' @param wikitable
#' Use [`class=wikitable`](https://www.mediawiki.org/wiki/Help:Tables#class="wikitable")
#' for tables, default is `TRUE`.
# nolint end
#'
#' @family wiki formats
#'
#' @seealso [MediaWiki markup
#' documentation](https://www.mediawiki.org/wiki/Help:Formatting)
#'
#' @return R Markdown output format to pass to [rmarkdown::render()].
#'
#' @export
mediawiki_document <-
function(keep_md = FALSE,
pandoc_args = NULL,
wikitable = TRUE) {
post_processor <-
function(metadata, input_file, output_file, clean, verbose) {
lns <- readLines(output_file)
lns <- gsub("\\{\\|", "\\{\\|class=wikitable", lns)
writeLines(lns, output_file)
output_file
}
rmarkdown::output_format(
knitr = rmarkdown::knitr_options(opts_chunk = list(dev = "png")),
pandoc = rmarkdown::pandoc_options(to = "mediawiki", args = pandoc_args),
keep_md = keep_md,
post_processor = if (wikitable) post_processor else NULL,
clean_supporting = FALSE
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.